-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile_ex.py
More file actions
81 lines (66 loc) · 970 Bytes
/
while_ex.py
File metadata and controls
81 lines (66 loc) · 970 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# example 1
i = 1
while i < 8:
print(i)
i = i + 1
# example 2
i = 1
while i < 6:
print(i)
i = i + 1
if i == 3:
break
# example 3
i = 1
while i < 6:
print(i)
i = i + 1
if i == 4:
break
#example 4
while True:
number = float(input("Enter a number"))
if number < 0:
break
print("You entered: ", number)
#example 5
for i in range(1, 51, 3):
if i == 7:
continue
else:
print(i, end=' ')
#example 6
for i in range(1, 51, 3):
if i == 7:
break
else:
print(i, end=' ')
#example 7
n = int(input("Enter n value"))
i = 0
while i <= n:
print(i)
i = i + 1
#example 8
i = 1
while i <= 10:
if i == 5:
pass
print(i)
i = i + 1
i = 1
list = []
while i <= 10:
list.append(i)
i += 1
print(list)
list1 = []
for i in range(1, 51, 3):
list1.append(i)
import matplotlib.pyplot as plt
import numpy as np
cnums = np.arange(5) + 1j * np.arange(6,11)
X = [x.real for x in cnums]
Y = [x.imag for x in cnums]
plt.scatter(X,Y, color='red')
plt.show()