Homework Assignment Number 3
- Read Chapter 3
- Create a .py file that includes
all written homework. It should be possible to load the python file
using idle and run it. It should not crash just by running it. You
should test this before submitting the file.
- Write a mathematically oriented
function of your choice that calculates something relevant to math or
science. Define a global variable and set it to the output of
call to this function.
Example: temp_today = faren_to_celcius(35)
- Write a function that:
- Takes one or more strings as
arguments
- Alters the strings by using
the concatenation operator '+' in some way.
- Prints helpful messages and
returns the altered string
Example:
month_day_year('January',31,2011)
Causes the following 3 lines of print:
Month = January
Day = 31
Year = 2011
Then it returns the string 'January
31, 2011
- Do the following in IDLE and write a
comment at the bottom of your .py file explaining the result:
- Run the following code and
then evaluate the variable output:
output
= 1
for number in range(1,5):
output
= output*number
- In a comment, labled #5,
explain why output has the value it does.
How the Homework will be graded
- Does the code run?
- Does it fulfill the assignment, anwer
the question asked, etc.?
- Is it clear?
- Do you use good variable names
- Do you use comments as appropriate
- When given latitude, do you
choose a really easy example, a medium example, a creative or
interesting example, etc.? I.e., Bells and whistles are never
required, but they may help your grade.