From da3820953bb994f7a86d3eb0e5fbb62235690005 Mon Sep 17 00:00:00 2001 From: Abhilash Date: Sat, 3 May 2025 18:35:09 +0530 Subject: [PATCH 1/2] saving_input_into_list.py --- saving_input_into_list.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 saving_input_into_list.py diff --git a/saving_input_into_list.py b/saving_input_into_list.py new file mode 100644 index 00000000000..03caac68016 --- /dev/null +++ b/saving_input_into_list.py @@ -0,0 +1,13 @@ +ran= int(input("Enter the range of elements you want to store / insert ")) +l1=[] +for i in range(ran): + l1.append(input("Enter here ")) + +print(l1) + + +""" +program first asks the user how many values they want to enter. Then, using a loop, it lets the user enter that many values one by one. +Each entered value is saved into a list called l1. Once all the values are entered, the program prints the complete list, showing +everything the user typed. It's a beginner-friendly way to learn how to collect multiple inputs and store them for later use. +""" \ No newline at end of file From 308bbea36144f27044dca8c248a58bd2ad322470 Mon Sep 17 00:00:00 2001 From: Abhilash Date: Sun, 4 May 2025 19:16:23 +0530 Subject: [PATCH 2/2] loops.py --- loops.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 loops.py diff --git a/loops.py b/loops.py new file mode 100644 index 00000000000..50d4ac6ef7b --- /dev/null +++ b/loops.py @@ -0,0 +1,40 @@ +# 2 loops + +# for loop: + +""" +Syntax.. +-> "range" : starts with 0. +-> The space after the space is called as identiation, python generally identifies the block of code with the help of indentation, +indentation is generally 4 spaces / 1 tab space.. + + +for in range(): + statements you want to execute + +for in : + print() +To print the list / or any iterator items + +""" + +# 1. for with range... +for i in range(3): + print("Hello... with range") + # prints Hello 3 times.. + +# 2.for with list + +l1=[1,2,3,78,98,56,52] +for i in l1: + print("list items",i) + # prints list items one by one.... + +for i in "ABC": + print(i) + +# while loop: +i=0 +while i<=5: + print("hello.. with while") + i+=1 \ No newline at end of file