Answer to Question #261389 in Python for Tatertatter

Question #261389

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-05T07:25:28-0400

for i in range(21):

  if i % 2:

    print("*")

  if i % 3:

    print("@")

  elif i % 4:

    print("$")

  else:

    print("!")

  print(i)


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