write a python program to display the number from 1 to 100?
Answers
Python program and the output for the above question is listed below :
Output :
"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".
Explanation:
for count in range(1,101):#for loop which runs for the value of 1 to 101.
print(count,end=" ")#print all the number.
Code Explanation ;
- The above code is in python because of the question suggestion, which holds the for loop which runs from 1 to 100 and scans all the number with the help of count variable.
- Then the print statement will print the one by one value with the help of the count variable. The value listed in one line because there is an end function in the print statement.
Learn More :
- Python : https://brainly.in/question/14689905
Here, we'll be using the for loop.
>>> for i in range(1, 101):
print(i)
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
Here, the value of 'i' keeps changing.
If you notice, range has two values, 1 and 101.
The syntax for range is (start, stop, step).
In this code, I've given the starting value as 1, ending value [stop] as 101.
When the program runs, the numbers usually start from 0. So for say, if the range had been:
range(1, 100)
It would've stopped at 99. But it however starts from 1 as we've given the starting value as 1.