The Joy of Programming
The For Loop
There is no preview available for this lesson. Please join the course to access it. Click here to enroll.
Questions
7.2
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(11): n=2**i print(n)
# your code here for i in range(11): n=2**i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
7.1
Mohamed Fariz K F
2 years ago
Post
Dismiss
# your code here for i in range(10): n = 10 - i print(n)
# your code here for i in range(10): n = 10 - i print(n)
Want to discuss?
Post it here, our mentors will help you out.
SL Sivani L R
3 years ago
Post
Dismiss
It was mentioned earlier that for range(n) it would give the values n to n-1 then how come in the above code : ___ for i in range(5): print('hello!') ___ it printed hello 5 times when it should have been printed 4 times ?
It was mentioned earlier that for range(n) it would give the values n to n-1 then how come in the above code : ___ for i in range(5): print('hello!') ___ it printed hello 5 times when it should have been printed 4 times ?
Anand Chitipothu
3 years ago
Post
Dismiss
If you count 0 to 4, there are 5 numbers. 0, 1, 2, 3 and 4. That is why it printed 5 numbers.
If you count 0 to 4, there are 5 numbers. 0, 1, 2, 3 and 4. That is why it printed 5 numbers.
Want to discuss?
Post it here, our mentors will help you out.