TORONTO KIDS COMPUTER CLUB | Friday Python Practice 20:30 – 22.09.02
21051
post-template-default,single,single-post,postid-21051,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Friday Python Practice 20:30 – 22.09.02

05 Sep Friday Python Practice 20:30 – 22.09.02

Question:
Create a loop between 1 to 20.

  • Print “fizz” if the number is divisible by 3
  • Print “bizz” if the number is divisible by 5
  • Print “fizzbizz” if a number is divisible by both 3 and 5.
  • Otherwise, print the number itself.

Hint: You should use % to get remainder of the division, so we can use it to calculate if the number is divisible by another number, for example 8 % 4 will give you 0, means 8 is divisible by 4.

No Comments

Sorry, the comment form is closed at this time.