Lab 2
Due 1:30PM February 5, 2007
- 1. Copy and paste or save hiho.py into a new
file.
2. Modify the program so that it prints “FIFO” .
- Write a program with the following three functions:
1. printFirstName - a function that prints your first name
2. printLastName - a function that prints your last name
3. printFullName - a function that prints your full name
Make sure to test each function by calling it. Verify that it produces
the correct result/side-effect.
- Write a program with the following functions:
1. add - this function takes as input two numbers, adds them, and displays
the result
2. subtract - this function takes as input two numbers, subtracts the
second from the first, and displays the result
3. multiply - this function takes as input two numbers, multiplies them,
and displays the result
4. quotient - this function takes as input two numbers, divides the first
by the second, and displays the result
Make sure to test each function by calling it. Verify that it produces
the correct result/side-effect.
- Modify your add/subtract/multiply/quotient program as follows:
1. Modify your functions such that they return the result calculated
2. Create two new functions, the first function should prompt the user
for a number. You will have to call this function twice, once to get
the
first number and once to get the second number. The second function
will take as input the results calculated by the functions add/subtract/multiply/quotient
and will display all four results for the user.
- Write an if statement that compares two integer variables x and y and
prints the largest. For example, your program would print “X is
larger than Y” or “Y is larger than X”.
- Modify your
program above so that it compares three integers x, y, and z and prints
the largest.
Sami Rollins