+ 3

Can someone give me a code of python in this question 🙏🏼

Write a program that displays multiple of 3 from 300 to 100

13th May 2021, 4:02 PM
Disha Jain
11 Answers
+ 5
First try then if there is problem on the code ask
13th May 2021, 4:03 PM
Matias
Matias - avatar
+ 3
n=0 for n in range(300,100,-1): if n%3==0: print(n) n=n+3 Yes this is working it gives the answer...indent below the print to get answer
13th May 2021, 4:14 PM
E.SANTHOSH
E.SANTHOSH - avatar
+ 1
Post your attempt first
13th May 2021, 4:04 PM
Atul [Inactive]
+ 1
Disha Jain i edited your code a little . added -1 as 3rd parameter to range and did proper indent to n+=3 line . n=0 for n in range(300,100,-1): if n%3==0: print(n) n=n+3
13th May 2021, 4:15 PM
TOLUENE
TOLUENE - avatar
+ 1
I think this is more correct... for n in range(300, 100 - 1, -1): if n % 3 == 0: print(n)
13th May 2021, 4:35 PM
Jan
Jan - avatar
0
n=0 for n in range(300,100): if n%3==0: print(n) n=n+3 I tried this...but this give me no output
13th May 2021, 4:06 PM
Disha Jain
0
Md Sayed thankuu so much
13th May 2021, 4:19 PM
Disha Jain
0
Hi😊 try adding steps in the range function☺. adding negative step will reserve movement, else you will find no output. range(300, 100, -1) if you want to learn more look at this -----> "The Python range() Function (Guide) – Real Python" https://realpython.com/python-range/
13th May 2021, 4:22 PM
Glitch
Glitch - avatar
0
print(*[n for n in range(300,100,-1) if n%3==0]) Or since the start of 300 is divisible by 3 you can step by -3: print(*range(300,100,-3))
13th May 2021, 5:33 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Disha Jain Here's the solution as a one-liner: for x in range(300, 100, -3): print(x) Or print(*range(300, 100, -3), sep='\n') # Hope this helps
14th May 2021, 7:21 PM
Calvin Thomas
Calvin Thomas - avatar
0
Just use the step value. for i in range (300,100,-3) : print (i) That's it .👍
15th May 2021, 8:11 AM
Swain