Must be done in python and using linux mint Write individual loops to do the fol
ID: 3700485 • Letter: M
Question
Must be done in python and using linux mint
Write individual loops to do the following a) Count from 0 to 100 (inclusive) by 1 - all output must be on a separate line b) Count by -3's from 3010 to 2999 - all output on the same line c) Count by 5's from 0 to 50 (inclusive) output each value in the next tab column d) Count by ½ from 20 to 30 (inclusive)-output one value per line e) Count from 1 to a number specified by the user with an increment of 2- output one value per line f) Count from a user-entered start value to a user-entered end value (do not display a value larger than the end value, you may display the end value) by a user-entered increment - output each value in the next tab column Enter a starting number> 3 Enter ending number > 21 Enter the increment 5 13 18 or Enter a starting number > 5 Enter ending number> 30 Enter the increment 6 10 15 20 25 30 Count from a user-entered start value by a user-entered increment, outputting a user- entered number of values output one per line g) e.g. Enter a starting number > 2 Enter increment>5 Enter the number of values to be output> 3 12Explanation / Answer
#a)
#count from 0 to 100 inclusive
for i in range(101):
print(i)#outputs on seperate line
#b)
#count by -3 from 3010 to 2999
i=3010
while(i>=2999):
print(i," ",end="")#output on same line
i-=3#decrement by -3
print()
#c)
#count by 5s from 0 to 50 inclusive
i=0
while(i<=50):
print(i," ",end="")#output on next tab
i+=5#increment by 5
print()
#d)
#count by 1/2 from 20 to 30 inclusive
i=20.0
while(i<=30.0):
print(i)#output on each line
i+=0.5#increment by 1/2
#e)
i=1
n = int(input("Enter number:"))
while(i<=n):
print(i)
i+=2#increment by 2
#f)
s = int(input("Enter a starting number:"))
e = int(input("Enter ending number:"))
n = int(input("Enter the increment:"))
while(s<=e):
print(s," ",end="")
s+=n
print()
#g)
s = int(input("Enter a starting number:"))
n = int(input("Enter the increment:"))
e = int(input("Enter the number of values to be output:"))
while(e>0):
print(s)
e-=1
s+=n
print()
output:
>>> ================================ RESTART ================================
>>>
0
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
3010 3007 3004 3001
0 5 10 15 20 25 30 35 40 45 50
20.0
20.5
21.0
21.5
22.0
22.5
23.0
23.5
24.0
24.5
25.0
25.5
26.0
26.5
27.0
27.5
28.0
28.5
29.0
29.5
30.0
Enter number:3
1
3
Enter a starting number:3
Enter ending number:21
Enter the increment:5
3 8 13 18
Enter a starting number:2
Enter the increment:5
Enter the number of values to be output:3
2
7
12
>>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.