TORONTO KIDS COMPUTER CLUB | Summer Camp 2021 Python Homework 16:30 – week 04
19882
post-template-default,single,single-post,postid-19882,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Summer Camp 2021 Python Homework 16:30 – week 04

29 Aug Summer Camp 2021 Python Homework 16:30 – week 04

Question 1:
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 could use % operator (find the division remainder) to check if the number is divisible by another number, such as: 14 % 7 the result would be 0, that means 14 is divisible by 7 or 14 is the multiples of 7.


Question 2:
Continue modify the war-robot program we made in the class, so that:

  • it will be the enemy’s turn to strike you back. Enemy can only use gun to fire and cause damage between 50-90.
  • after enemy’s turn, if your hp is lower or equal to 0, use msgbox to display message ‘you lose’, and the while program finish.

Question 3:

We have a list of following:

zoo = ['monkeys', 'tigers', 'pandas', 'penguins', 'giraffes', 'hippos', 'bears']

how to retrieve a slice of list zoo, so you can get the following results?

['tigers', 'pandas', 'penguins', 'giraffes']
['hippos', 'bears']
No Comments

Sorry, the comment form is closed at this time.