-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.py
More file actions
54 lines (45 loc) · 894 Bytes
/
Copy pathLoops.py
File metadata and controls
54 lines (45 loc) · 894 Bytes
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
# Problem 1
# Question : Write a loop program to print 1 to 5 on one by one.
# Output :
# 1
# 2
# 3
# 4
# 5
# def main():
# for i in range(1,5):
# print(i)
# if __name__ =="__main__":
# main()
# Problem 2
# Question : Write a loop program to print 5 to 1 on one by one.
# def main():
# for i in range(5,0,-1):
# print(i)
# if __name__ =="__main__":
# main()
# Problem 3
# Question : Write a loop program to print sum of 1 to 5.
# Output : 15
# sum=0
# for i in range(1,6):
# sum=sum+i
# print(sum)
# Problem 4
# Question :Write a loop program to print sum of 5 to 1.
# Output : 21
# sum=0
# for i in range(5,0,-1):
# sum=sum+i
# print(sum)
# Problem 5
# Question : Write a loop program to print odd numbers 1 to 9.
# Output :
# 1
# 3
# 5
# 7
# 9
for i in range(1,10):
if i%2!=0:
print(i)