Estás en:   ArielOrtiz.com > Fundamentos de programación > Práctica #2: Aritmética simple

Práctica #2: Aritmética simple

Objectives

During this activity, students should be able to:

This activity helps students develop the following skills, values and attitudes: proficiency in English, ability to analyze and synthesize, capacity to identify and solve problems, and efficient use of computer systems.

Activity Description

Individually or in pairs, solve the following set of problems using Python 3.5. Run and test each of your programs to make sure they work as expected.

Each source file must include at the top the authors’ personal information (student ID and name) within comments. For example:

# Authors: 
#          A01166611 Pepper Pots
#          A01160611 Anthony Stark
#
# Description of problem being solved.
#
# February 1, 2017.

    .
    . (The rest of the program goes here)
    .
  1. Five Star Video rents new videos for $3.00 a night, and oldies for $2.00 a night. Write a program called video.py that the clerks at Five Star Video can use to calculate the total charge for a costumer’s video rentals. The program should prompt the user for the number of each type of video and output the total cost.

    Example (user input is in blue):

    Number of new videos to rent: 3
    Number of old videos to rent: 5
    Total charge for costumer's video rentals: $ 19
    
  2. There are 1024 bytes in a kibibyte (KiB), and there are 1024 kibibytes in a mebibyte (MiB). Write a program called byte.py that accepts a number of bytes as input and converts that value into mebibytes.

    Example (user input is in blue):

    Number of bytes: 4718592
    4718592 is equal to 4.5 MiB.
    
  3. An object’s momentum is its mass multiplied by its velocity. Write a program called momentum.py that accepts an object’s mass (in kilograms) and velocity (in meters per second) as inputs and then outputs its momentum.

    Example (user input is in blue):

    Object's mass in kilograms: 4.6
    Object's velocity in meters per second: 1.2
    The object's momentum is: 5.52 kg m/s
    
  4. The kinetic energy of a moving object is given by the formula:

    KE = (1/2)mv2

    where m is the object’s mass and v is its velocity. Write a program called kinetic.py that prints the object’s kinetic energy as well as its momentum (see the previous problem).

    Example (user input is in blue):

    Object's mass in kilograms: 4.6
    Object's velocity in meters per second: 1.2
    The object's kinetic energy is: 3.312 joules
    The object's momentum is: 5.52 kg m/s
    
  5. Write a program called minutes.py that calculates and prints the number of minutes in a year (assume that a year has 365.25 days).
  6. Light travels 299,792,458 meters per second. A light-year is the distance a light beam travels in one year. Write a program called light.py that calculates and displays the value (in meters) of a light-year (assume that a year has 365.25 days).
  7. In biology, the total population T based on a generation number can be calculated using this formula:

    T = ICn

    Where I is the initial population, C is the number of offspring per parent, and n is the generation number.

    Write a program called population.py that takes I, C, and n as inputs and prints the corresponding total population.

    Example (user input is in blue):

    Initial population: 3
    Number of offspring per parent: 5
    Generation number: 10
    Total population is 29296875
    
  8. Write a program called nautical.py that takes as input a number of kilometers and prints the corresponding number of nautical miles. Use the following approximations:

    • A kilometer represents 1/10,000 of the distance between the North Pole and the equator.
    • There are 90 degrees between the North Pole and the equator.
    • One degree is equal to 60 arcminutes.
    • One nautical mile is equal to one arcminute.

    Example (user input is in blue):

    Number of kilometers: 12.5
    12.5 kilometers is equal to 6.75 nautical miles.
    
  9. An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program called wage.py that takes as inputs the hourly wage, total regular hours, and total overtime hours and displays an employee’s total weekly pay.

    Example (user input is in blue):

    Hourly wage: 7.25
    Total regular hours: 35.5
    Total overtime hours: 5.5
    Employee's total weekly pay is: $ 317.1875
    
  10. Write a program called rain.py that accepts as input the depth of rain (in inches) that has fallen over an acre of land. The program should calculate and print the water volume (in gallons) accumulated on that acre.

    You will need to use the following conversion formulas:

    • 1 foot = 12 inches
    • 1 acre = 43560 square feet
    • 1 cubic foot = 7.48052 gallons

    Example (user input is in blue):

    Depth of rain (in inches): 5.9
    5.9 inches of rain over one acre of land is equal to 160210.29684 gallons.
    

Problems taken from:

Kenneth Lambert.
Fundamentals of Python: From First Programs through Data Structures.
CENGAGE Learning, 2010.
p. 74.

Deliverables

Create a ZIP file called simple.zip containing the ten programs you wrote (video.py, byte.py, momentum.py, kinetic.py, minutes.py, light.py, population.py, nautical.py, wage.py, and rain.py).

✔ Upload Instructions

To deliver the simple.zip file, please provide the following information:

Request PIN

If this activity was developed by a team of two people, only one person is required to deliver it. No activity will be accepted through any other means.

Due date is Wednesday, February 1.

Evaluation

This activity will be evaluated using the following criteria:

-10 One or more programs don’t contain within comments the authors’ personal information.
DA One or more programs were plagiarized.
10-100 Depending on the amount of problems that were solved correctly.