-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhileLoop.py
More file actions
77 lines (58 loc) · 1.2 KB
/
whileLoop.py
File metadata and controls
77 lines (58 loc) · 1.2 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
74
75
76
77
# WAP to print numbers from 1 to 100
""" i=1
while i<=100:
print(i)
i+=1 """
# WAP to print numbers from 100 to 1
""" i=100
while i>=1:
print(i)
i-=1 """
# WAP to print multiplication tble of a number n
""" n=int(input("Enter a number: "))
i=1
while i<=10:
print(n*i)
i+=1 """
# WAP to print the element of the following list usin a loop
""" nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
lenght = len(nums)
i=0
while i<=lenght-1:
print(nums[i])
i+=1 """
# Search for a number x in this tuple using loop
""" nums = (1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
x = 9
i = 0
while i< len(nums):
# print(nums[i])
if (nums[i]==x):
print("Found at index", i)
break
i+=1 """
# break keyword
""" i = 1
while i <= 10:
print(i)
if(i == 8):
break
i += 1
print("End of loop") """
# continue keyword
""" i = 1
while i <= 10:
if(i == 5):
i += 1
continue # continue ke baad ke steps skip ho jayege
print(i)
i +=1 """
# WAP to print even numbers from 1 to 10
i = 1
while i <= 10:
if(i % 2 != 0):
i += 1
continue
print(i, end=' ')
i +=1
# end=' ' it is used to print without a newline