-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFOR loop.py
More file actions
70 lines (49 loc) · 1.07 KB
/
Copy pathFOR loop.py
File metadata and controls
70 lines (49 loc) · 1.07 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
#FOR LOOP
i = 1
for i in range(1, 11):
print(i , end=" ")
print("")
bag=("red","green","yellow")
# STEP in FOR LOOP
for ball in bag:
print(ball)
for i in range(1, 11 , 2):
print(i , end=" ")
print("")
#using enumerate
name = "kirana"
for index, letter in enumerate(name):
print(letter*(index+1))
l= [12,13,56,33,44]
for index, num in enumerate(l):
print(f"{num}is in {index}th index")
#using break in a for loop
cities= ["bengalore","mysore","udupi","hubbali"]
for city in cities:
if city == "shivamogga":
print(f"found {city}!")
break
else:
print("not found")
print("")
for city in cities:
if city == "shivamogga":
continue
print(city)
#FOOR LOOP ON DICTIONARY
d = {
"NAME":"KIRANA",
"AGE":23,
"INCOME":1
}
for key,value in d.items():
print(key, " ",value)
#5 table using for loop
num = 5
for i in range (1,11):
print(f"{num} x {i} = {num*i}")
# create table from 1 to 10 using nested for lop
for i in range(1,11):
for j in range(1,11):
print(f"{i} x {j} = {i*j}")
print("")