0

Please who knows how to print even numbers in python using while loop

Python Coding

14th May 2022, 3:38 PM
David Tosin
David Tosin - avatar
7 Answers
+ 3
You can use modulo division operator for check if a number is even. Try to do that in an attempt on Sololearn Playground and link with your question.
14th May 2022, 3:52 PM
JaScript
JaScript - avatar
+ 3
#Even numbers from 0 to 100 i = 0 while i<=100: print(i) i += 2
14th May 2022, 4:24 PM
MD. Ferdous Ibne Abu Bakar
MD. Ferdous Ibne Abu Bakar - avatar
+ 1
First, you'll have to see how till how many you want to print. So for eg. Even numbers till 10 will be like this i = 1 # Run a loop 10 times while i <= 10: # Check if i is an even number. if yes, then print it if i % 2 == 0: print(i) i += 1
14th May 2022, 3:49 PM
Usman Sabuwala
Usman Sabuwala - avatar
+ 1
Thank you
14th May 2022, 3:56 PM
David Tosin
David Tosin - avatar
0
i = 0 while i <= 100: print(i := i +2)
14th May 2022, 4:45 PM
Umar Farooq
0
Or, i = 0 while i <= 100: print(i := i +2)
16th May 2022, 10:30 AM
Hrithik Nayak
- 2
You can use modulo division operator for check if a number is even. Try to do that in an attempt on Sololearn Playground and link with your question.
16th May 2022, 10:29 AM
Hrithik Nayak