Lab 3
Lab 3
Lab Requirements
PyCharm (IDE).
Version 1.2
05/10/2019
Practice Activities with Lab Instructor (20 minutes)
Write a program that reads in the radius and length of a cylinder and computes the area
and volume using the following formulas:
Solution
2
activity_1.py
1 # Enter radius of the cylinder
2 radius, length = eval(input("Enter the radius and length of a cylinder: "))
3
4 # Calculate the area of the cylinder
5 area = radius * radius * 3.14159
6 # Calculate the volume of the cylinder
7 volume = area * length
8
9 # Print the results
10 print("The area is", area)
11 print("The volume is", volume)
Write a program that prompts the user to enter the minutes (e.g., 1 billion), and displays
the number of years and days for the minutes.
For simplicity, assume a year has 365 days. Here is a sample run:
Solution
4
Individual Activities (60 minutes)
Write a program that reads a Celsius degree from the console and converts it to
Fahrenheit and displays the result. The formula for the conversion is as follows:
Write a program that calculates the energy needed to heat water from an initial
temperature to a final temperature. Your program should prompt the user to enter the
amount of water in kilograms and the initial and final temperatures of the water. The
formula to compute the energy is:
where M is the weight of water in kilograms, temperatures are in degrees Celsius, and
energy Q is measured in joules. Here is a sample run:
5
Extra Exercises (Homework)