Professional Documents
Culture Documents
IT2 Lab5 Tasks
IT2 Lab5 Tasks
For the tasks 1- 4 do NOT execute Python software and try to write the
answers for the following problem below.
2. Write a Python general-purpose function named findAbs( ) that accepts a float number
passed to it, computes its absolute value, and displays the absolute value.
For the tasks 5-11 solve the problems executing Python programs (use
Spyder-Anaconda environment).
For each solution do the print screen of your full display (incl. the code and
output windows) and paste the pictures in the document. Upload it to Wikamp
- Exercises Lab 5.
5. Write a program that determines the time it takes a ball to hit the ground after it has
been dropped from an 800-foot tower. The mathematical formula to calculate the time, in
seconds, that it takes to fall a given distance, in feet, is:
time = sqrt (2 * distance / g)
where g is the gravitational constant equal to 32.2 ft/sec^2.
6. A model of worldwide population, in billions of people, after the year 2000 is given by
the equation
population = 6.0 e 0.02 [Year – 2000]
Using this formula, write a Python program to estimate the worldwide population in the
year 2021 and in the 2030.
8. According to Plato, a man should marry a woman whose age is half his age plus seven
years. Write a program that requests a man’s age as input and gives the ideal age of his
wife. Use two separate functions for input and output.
9. To determine the number of square centimeters of tin needed to make a tin can, add the
square of the radius of the can to the product of the radius and height of the can, and then
multiply this sum by 6.283.
Write a program that requests the radius and height of a tin can in centimeters as input
and displays the number of square centimeters required to make the can. Use two
separate functions for input and output.
10. The original cost of airmail letters was 5 cents for the first ounce and 10 cents for each
additional ounce. Write a program to compute the cost of a letter whose weight is given by
the user. Use at least two functions.
Hint: Use the function ceil( ). Test the program with weights 4, 1, 2.5, 0.5 ounce.
11. A fast-food vendor sells pizza slices ($1.25), fries ($1.00), and soft drinks ($0.75).
Write a program to compute a customer’s bill. The program should request the quantity of
each item ordered in a first function, calculate the total cost with a second, and use the
third to display an itemized bill. The sample output is presented below: