-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5.py
65 lines (54 loc) · 1.04 KB
/
5.py
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
# #Write the python programs, which prints the following sequences of values in loops:
#a) 24, 18, 12, 6, 0, -6
x = 24
while x >= -6:
if x == -6:
print(x, end= " ")
else:
print(x, end= ", ")
x -= 6
print()
#b)-10, -5, 0, 5, 10, 15, 20
x = -10
while x <= 20:
if x == 20:
print(x, end= " ")
else:
print(x,end = ", ")
x += 5
print()
# print("Input: 18, 27, 36, 45, 54, 63")
x = 18
while x <= 63:
if x == 63:
print(x, end = ' ')
else:
print(x, end = ', ')
x += 9
print()
#'18,-27, 36,-45,54,-63'
count = 0
val = 18
while val <= 63:
count +=1
if count % 2 == 0:
if val == 63:
print('-'+str(val), end = ' ')
else:
print('-'+str(val), end = ', ')
else:
print(val, end = ', ')
val += 9
print()
#prev solve:
x = 18
while x <= 63:
if x%2 ==1:
if x == 63:
print(-x, end =" ")
else:
print(-x, end= ", ")
else:
print(x, end = ", ")
x += 9
print()