TORONTO KIDS COMPUTER CLUB | Sunday 16:00 Python Homework 07.14
16396
post-template-default,single,single-post,postid-16396,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Sunday 16:00 Python Homework 07.14

16 Jul Sunday 16:00 Python Homework 07.14

Hint for Previous Class Questions:

Hints for Question 1:

  1. You need use for loop for this question
  2. In the loop you need use if statement to compare the number with your input
  3. If it is the same number, please use continue to the next iteration
  4. Be careful of the data type conversion from string into integer when you use input

 

Hints for Question 2:

  1. Be careful of the data type conversion from string into number when you use input

 

Hints for Question 3:

  1. Be careful of the data type conversion from string into integer when you use input
  2. Using % (modulus, remember? it is the remainder of the division of one number by another, for example, the result of 15%3 is 0) to check if the number is divisible by another number
  3. Using if …. elif …. else for the condition check

This Class Questions:

Question 1.

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 result?
[‘monkeys’, ‘pandas’, ‘giraffes’, ‘bears’]


Question 2.
How to get average number of the following  list mynumber?
mynumber = [‘3’, ‘6’, ‘2’, ‘8’, ‘9’, ’10’, ’30’]

Hint:

  • We can use len(mynumber) to get how many items in the list
  • Be careful about data type of the item in the list
No Comments

Sorry, the comment form is closed at this time.