TORONTO KIDS COMPUTER CLUB | Aurora Saturday 16:30 Python Homework 21.04.03.
post-template-default,single,single-post,postid-19259,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

Aurora Saturday 16:30 Python Homework 21.04.03.

07 Apr Aurora Saturday 16:30 Python Homework 21.04.03.

Question 1.
Modify the following program so that it still prints the string "What's that?", but this time it uses an escape character.

The outer quotation marks are used to show where the string begins and ends. They will not show up when the string is printed.


Question 2.
Write a program that uses an escape character to print the string "first" on the first line and the string "second" on the second line.

Question 3:
You are in a bike race which goes up and down a hill. You could create two variables: uphillDistance and downhillDistance give the distance (in km) of both parts of the race. Write a program that will print out the total distance for the entire race.

Sample Input:
Uphill distance: 3
Downhill Distance: 5

Sample Output:
The total distance is 8 km

Question 4:
Write a program to help you feed your friends at a party by doing some math about square pizzas. Your program need use input to ask the side length of the square pizza in cm. The area of the pizza should be computed using the formula Area = side length * side length. Then, assuming that each person needs to eat 100 cmof pizza, calculate the number of people it can feed.

Sample Input:
Side length of the square pizza: 17.5

Sample Output:

Explanation and Hint:
If the side length is 17.5, the area will be 306.25 cm2, so 3 is the correct output, because it 3 persons need to eat 300 cm2 in total. You can get this result by using int(), for example:

people = int(306.25 / 100)

this will help you round down the result into 3

No Comments

Sorry, the comment form is closed at this time.