Lab 3

Due 1:30PM February 12, 2007

  1. Write a program to calculate the amount of money the user will receive on his/her paycheck. Your program will prompt the user for his/her base hourly pay rate and the number of hours he/she worked and calculate the total pay. Your program should appropriately calculate overtime pay; any hours worked in excess of 40 should be paid at a rate of 150% of the base pay. For example, if the user worked 55 hours at $10 per hour, the total pay would be (40x10)+(15*(10*1.5)). Use functions where appropriate.
  2. Write a while loop that prints all of the even numbers between 1 and 100.
    Create two versions of this loop, one that uses an if statement and one that does not.
  3. Write a program that uses the module random to select a random number between 1 and 10 (example below) and asks the user to repeatedly enter a number until he/she has guessed the random number.
    #import the module random
    import random
    #call the randint function passing in the range
    num = random.randint(1, 10)
  4. Design a program which prompts the user for a number of rows between 0 and 10 and prints the following pattern:
    ****
    ***
    **
    *
  5. Design a program which prompts the user for a number of rows between 0 and 10 and prints the following pattern:
       *
      * *
     * * *
    * * * *


Sami Rollins