RHHS Compsci 2016
Although the labels don’t impact the contents inside the cans, they show you, the hungry
person, all the necessary details of the food inside.
In the context of programming, think of comments as labels to several pieces of your code.
They help you keep track of what your code does and how it contributes to the overall
program. Even in simple programs you should comment as you code in order to develop the
To write a comment, simply put a # in front of your label or what you wish to be ignored.
Comments will be highlighted red.
Practice is important to help you apply these skills
Ask the user for a mark (integer from 0 to 100 inclusive) and print out what letter-grades
they would receive. From 80 to 100 is an A, 70 to, but not including, 80 is a B, 60 to, but
not including, 70 is a C, and 50 to, but not including, 60 is a D. Below 50 is an F.
Ask the user for three things: height and radius. When they have given both, print out the
volume of the cylinder that would be formed. The formula for the volume of a cylinder is
(π * r2 * h). Do the same for the surface area (try to derive the formula on your own!).
For π, you can use math.pi.
A slice of pizza contains 355 calories. Cycling at a certain pace burns around 550 calories
per hour. Write a program to figure out how long you would have to cycle to burn off a
certain number of pizza slices (ask the user!). Give your answer in hours and minutes
(rounded to the nearest minute).
Write the necessary Python code to generate a random integer number between –5 and
17 inclusive (including both –5 and 17). See above for a hint. (Ridout)