-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython_12Forloop.py
More file actions
73 lines (43 loc) · 1.35 KB
/
Python_12Forloop.py
File metadata and controls
73 lines (43 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
For loop 3 fundamentals
1- start -1
2- stop - 10
3- Step - ++increment,--decrement,etc.
SYNTAX:
for i in range(start,stop,step):
statements
include or exclude
"""
for i in range(1,10): #here 1 is include and 10 is excluded
print(i)
print("\n")
for i in range(1,11): #here we increase the value by 1 so that whole range gets covered
print(i)
print("\n")
for i in range(1,11,2): #next value will be added by +2
print( i,"\n",i*i)
#Take 2 inputs from the user and print their list
# m=int(input("Enter start number :"))
# n=int(input("Enter End number :"))
# for i in range(m,n+1):
# print(i) #by taking i ORRRRR ⬇️⬇️⬇️
# #⬇️
# print(m) #By Taking m
# m+=1 #important otherwise it will only print the first initial values for n times
#NOW , For printing in reverse
m=int(input("Enter start number :"))
n=int(input("Enter End number :"))
for i in range(m+1,n,-1):
print(m)
m-=1
#Print all the number between 1-100 which are divisible by 3
for i in range(1,100):
if i%3==0:
print(i)
#Taking the input itself from the user about the range and the divisiblity number to check
m=int(input("Enter start number :"))
n=int(input("Enter End number :"))
o=int(input("Enter the divisible number: "))
for i in range(m,n+1):
if i%o==0:
print(i)