TORONTO KIDS COMPUTER CLUB | Friday 19:00 Homework
160

# Friday 19:00 Homework

## 14 DecFriday Python Practice 19:00 – 22.12.09

Question 1： Make a class definition for a  BankAccount. It should have attributes for : – its name (a string), – account number (a string or integer), – and balance (a float). It should have methods to: – make deposits with displaying the balance, – and make withdrawals with displaying the balance. Hint: Question 2： Create...

## 07 DecFriday Python Practice 19:00 – 22.12.02

Question: You are given a string . Suppose a character ‘a’ occurs consecutively n times in the string. Replace these consecutive occurrences of the character ‘a’ with (n, ‘a’) in the string. Input Format:  A single line of input consisting of the string . Output Format: A single line of...

## 30 NovFriday Python Practice 19:00 – 22.11.25

Question 1： Write a program that asks the user to enter his/her name, age, favorite color, and favorite food. Have the program save all four items to a text file called myinfo.txt, each one on a separate line. Question 2： Write a program that asks the user to enter...

## 23 NovFriday Python Practice 19:00 – 22.11.18

Question: Given the list of student marks: marks = [62, 84, 74, 51, 98, 73, 77, 90, 85, 79, 65, 58, 74, 86] Write a function that takes in a list of arguments and then returns a list containing marks which are above average. Name the function whatever you like...

## 16 NovFriday Python Practice 19:00 – 22.11.11

Question: The factorial function (symbol: !) says to multiply all whole numbers from our chosen number down to 1. Examples: 4! = 4 × 3 × 2 × 1 = 24 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040 1! = 1 Factorial is not defined for...

## 08 NovFriday Python Practice 19:00 – 22.11.04

Question： The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in meters) and weight (in kilograms), then calculates the BMI using the formula: BMI = weight / (height * height) Write a program...

## 31 OctFriday Python Practice 19:00 – 22.10.28

Question 1：(please use function that return a value) Write a program to display information to a driver based on his/her speed according to the following table: km/h over the limit Fine 1 to 20 \$100 21 to 30 \$270 31 or above \$500 Sample Input 1: Enter the speed limit: 40 Enter the recorded speed of the...

## 24 OctFriday Python Practice 19:00 – 22.10.21

Question 1: Make a function that will allow you to print any name, address, street, city, state or province, zip or postal code, and country in the world. (Hint: It needs seven arguments. You can pass them as individual arguments or as a list.) Question 2: Write a function to calculate the total value of some...

## 17 OctFriday Python Practice 19:00 – 22.10.14

Question： Create a list called “attributes” , it contains “HP”, “Attack”, “Defense”, “Special Attack”, “Special Defense”, “Speed” Modify the list above, replace “Special Attack” and “Special Defense” with “Magic” and “Stamina” Add “Special skills” in the end of the list Delete “Speed” from the list. ...

## 12 OctFriday Python Practice 19:00 – 22.10.07

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 results? ['tigers', 'pandas', 'penguins', 'giraffes'] ['hippos', 'bears'] Question 2： Using split and join function of the list to change string "green,red,yellow,blue," into string: "green...