Training Exercises
Training Exercises
1. Build an Object-oriented Python script that allows converting a quantity entered in meters to millimeters,
centimeters, decimeters, Decameters, Hectometers, and Kilometers. Show an error if the entered value
is less than zero.
2. Build an Object-oriented Python script that allows entering the number of days worked (must be
between 1 and 15) for a particular job performed by an employee. The employee is paid $ 50,000.oo per
day worked, and 5% of the total accrued is deducted for health and retirement plan payments. Calculate
and publish the total money that the worker receives once the discount has been made.
3. Build an Object-oriented Python script that allows typing two integer values. Show an error message if
the product of the two values is negative or zero; otherwise, exchange their values so that the first
variable remains with the value of the second and the second variable remains with the value of the
first; publish the new values.
4. In forensic science, it is possible to calculate the approximate height of a person based on the length of
the femur bone. Build an Object-oriented Python script that allows the user typing the length of the
femur bone (validating that it is greater than zero) and calculate its approximate height through the
following equation: H = 1.880 x L + 32.010
5. In archeology, several square-based pyramids have been found in different civilizations. An
archaeologist has the data of the height and the length of one of the sides of the base of several
pyramids. Build an Object-oriented Python script that allows calculating the volume of a pyramid with a
square base given the values of its height and the length of one of the sides of the base. Validate that all
provided values are greater than zero.
6. Build an Object-oriented Python script that allows the user typing three positive integer values (validate
such a condition) and then report which of them is the greatest.
7. Build an Object-oriented Python script that allows the force to be calculated as a function of a mass and
an acceleration given by the user. Show an error message on negative values given by the user.
8. Build an Object-oriented Python script that allows the user typing three negative integer values
(validate such a condition) and then report which of them is the smallest.
9. In archeology, several cylindrical totems have been found in different civilizations. An archaeologist has
the data of the height and the radius of the base of several cylindrical totems. Build an Object-oriented
Python script that allows calculating the volume of a cylindrical totem given the values of its height and
the length of the radius of its base. Validate that all provided values are greater than zero.
10. Build an Object-oriented Python script that allows converting an integer between 1 and 10 to Roman
notation. If the entered number is not in such range, show a message to the user to properly type the
value.
11. Build an Object-oriented Python script that allows converting degrees Celsius to Fahrenheit (please
investigate theconversion formula). If the user enters a number lower than absolute zero in
temperature (please investigate the value of absolute zero), an error message will be displayed.
12. Build an Object-oriented Python script that allows solving a first-degree equation considering the
values of the coefficients given by the user.
This is the general expression of the equation: ax + b = 0
Please consider the restrictions below:
if a <> 0, solution is x = -b/a
if a is 0 and b is not 0, the script must show the message “impossible solution” if a is 0
and b is 0, the script must show the message “indeterminate solution”