Individual Programming Activity
Functions
Activities
I would like you to attempt to complete four small python functions by working on your own. If you get stuck you can ask a question of a classmate that helps you figure out the solution, although you should not copy code.
Please try to make your program output look as much like the examples as possible and verify it works with the example input provided. If you have difficulty finding the information or understanding how to approach the problem, you should contact me.
To complete this activity, you will need to create the following scripsts:
- Func 5 - rectangleArea()
- Func 6 - simplePaycheck()
- Func 7 - discountPrice()
- Func 8 - howFar()
The Replit documents for each of these problems is located at:
- Replit Code Link - https://replit.com/team/Cohort23
Func 5
Rectangle Area
Polly Gahn is a carpet installer who wants help calculating the area of a room.
Write a Python function that conforms to the following
- Function name:
- rectangleArea()
- Parameter(s)
- the length of the room
- the width of the room
- Return value
- the area of the room
- as calculated. You should not round/format the answer in any way
- Example(s)
Func 6
Simple Paycheck
Anita D'Monet is the accountant for a local business and is responsible for writing paychecks
Write a Python function that conforms to the following
- Function Name
- simplePaycheck()
- Parameter(s)
- the number of hours worked
- the salary per hour
- Return value
- the amount of the paycheck
- as calculated. You should not round/format the answer in any way
- Example(s)
Func 7
Discount Price
Brice Tagg wants you to create a program to help her calculate sale prices in her store.
Write a Python function that conforms to the following
- Function name
- discountPrice()
- Parameter(s)
- original price (of an item)
- percentage off
- Return value
- the sales price for the item as calculated
- you should not round the answer in any way
- Example(s)
Func 8
How Far
Wayne Ningmoon teaches middle school science. He is currently teaching a unit on space exploration. He wants your help calculating where the Voyager 1 spacecraft currently is located.
Write a Python function that conforms to the following
- Background
- Voyager 1 was launched by NASA on September 15, 1977.
- It is the farthest-traveling Earth-made object.
- It actually left the bounds of our solar system in August of 2012.
- As of April 1, 2022 the spacecraft was located ~14,500,000,000 miles from the sun.
- It is traveling away from the sun at a speed of ~38,027 miles per hour.
- Function Name
- howFar()
- Parameter(s)
- Days since April 1, 2019
- Return value
- the approximate distance between the sun and Voyager 1 based on the previous information
- Example(s)
- Special Instructions
- The calculations above are estimates. To see the actual distance right now you can visit the Voyager status page on the NASA website.