0

How to get all the numbers that are divisible by 2 in python?

In a list form or open form

7th Apr 2020, 3:56 PM
COMRADE
COMRADE - avatar
5 Antworten
+ 4
Hello Poorna Sasank Please show us your attempt so that we can help you.
7th Apr 2020, 4:09 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Ok
7th Apr 2020, 4:18 PM
COMRADE
COMRADE - avatar
0
I don't know how to so I asked this question
7th Apr 2020, 4:09 PM
COMRADE
COMRADE - avatar
0
You need a loop and an if statement. if i % 2 == 0: print(i) If a number is divisble by 2, print it or put it in a list. Read the lesson about for loops than you should be able to solve this task :)
7th Apr 2020, 4:18 PM
Denise Roßberg
Denise Roßberg - avatar
0
Enter the numbers for example : 10 or 20 or 30............n a=int(input("enter number of terms:")) for i in range(a+1): if i%2==0: print(i)
8th Apr 2020, 3:28 AM
Ashish Singh
Ashish Singh - avatar