Create a project folder username_a03
. Place all your tasks python files(t01.py
,
t02.py
,t03.py
) and the testing file testing.txt
inside this folder. Upon
completing your tasks, export your projrct folder to username_a03.zip
file, validate it, and
submit it to the dropbox by the due date.
Write and test the following function:
def feet_to_acres(square_footage):
"""
-------------------------------------------------------
Converts square footage to acres.
Use: acres = feet_to_acres(square_footage)
-------------------------------------------------------
Parameters:
square_footage - area in square feet (float >= 0)
Returns:
acres - square_footage in acres (float)
------------------------------------------------------
"""
Add the function to a PyDev module named functions.py
.
Test it from .
There are 43,560 square feet per acre. Define this value as a global
constant outside of the function in functions.py
.
The function does not ask for input and does no printing - that is done by your test program.
Sample testing:
Square footage: 100000 2.30 acres is equivalent to 100,000.00 square feet
Test the function with three different sets of parameters.
Partial testing:
Write and test the following function:
def date_extract(date_number):
"""
-------------------------------------------------------
Extracts the year, month, and day from a date number in the format MMDDYYYY.
Use: year, month, day = date_extract(date_number)
-------------------------------------------------------
Parameters:
date_number - a date number in the format MMDDYYYY (int > 0)
Returns:
year - year portion of date_number (int)
month - month portion of date_number (int)
day - day portion of date_number (int)
------------------------------------------------------
"""
Add the function to a PyDev module named functions.py
.
Test it from .
The function must use integer division and modulus, not strings, to extract the date parts. The function does not ask for input and does no printing - that is done by your test program.
Sample testing:
Enter a date in the format MMDDYYYY: 10251962 The reformatted date: 1962/10/25
Test the function with three different sets of parameters.
Partial testing:
Write and test the following function:
def multiply_fractions(num1, denom1, num2, denom2):
"""
-------------------------------------------------------
Multiplies two fractions together and returns the results
Use: numerator, denominator, product = multiply_fractions(num1, denom1, num2, denom2)
-------------------------------------------------------
Parameters:
num1 - numerator of the first fraction (int)
denom1 - denominator of the first fraction (int)
num2 - numerator of the second fraction (int)
denom2 - denominator of the second fraction (int)
Returns:
numerator - numerator of the resulting fraction (int)
denominator - denominator of the resulting fraction (int)
product - numerator divided by denominator (float)
------------------------------------------------------
"""
Add the function to a PyDev module named functions.py
.
Test it from .
Sample testing:
Numerator 1: 1 Denominator 1: 2 Numerator 2: 3 Denominator 2: 4 Result: 3/8 = 0.375
Test the function with three different sets of parameters.
Partial testing:
Partial testing of functions.py:
Partial testing of testing.txt: