Answer to Question #261369 in Python for tatertator

Question #261369

Create a for-loop that loops from 0 up to and including 20. On each iteration, output a '*' (an asterisk) if the value of the counter variable is divisible by 2, a '@' if divisible by 3, and a '$' if divisible by 4. In all other cases, output a '!'. Each symbol should be printed on a different line.


1
Expert's answer
2021-11-05T17:26:08-0400
for i in range(0,20):
    if i%2==0:
        print("*")
    elif i%3==0:
        print("@")
    elif i%4==0:
        print("$")
    else:
        print("!")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog