Exercise Guru

Exercise Rules


We now have several weeks of coding under our belt, we are beginning to be able to create more sophisticated computer programs.  However, just with physical training, if we don’t exercise ourselves, we could lose what we’ve learned.  Exercise will help us hone these skills.  That’s what this lesson is about, “Use it, or lose it!”

Programming 1 Exercise Set #1

Write a program for each specified task.  Name these files as yourname-set1-prob1.py, yourname-set1-prob2.py, etc…

  1. Read the information at this link on compounding interest.  Write a program that accepts values of P, r, n, and t from the user and displays the new amount.  Test your program for $100 earning 6% interest compounded annually.

    Concepts required:  input/output, assignment, multiplication, addition, exponents

  2. A set of numbers is to be typed at the keyboard.  After each number other than 0 is entered, the program should display the count and sum of all the numbers entered to that point.  When the user enters 0, the average of the input values should be displayed and the program should end.

    Concepts Required:  loops, counters, addition, division, input/output

  3. A person wishes to determine the dollar amount of any collection of U.S. coins, simply be specifying now many coins of each type of coin are included.  Your program should assist the user in this task.

    Concepts Required:  input/output, multiplication, addition

  4. Two numbers X and Y are to be typed. If the sum of X and Y is greater than 42, the program should display the message The sum is greater than 42.  If the sum is not greater than 42, the program should increase X by 10 and decrease Y by 3, display these new values, and again check to see whether the sum is greater than 42.  The program should repeat this process until the message The sum is greater than 42 is displayed.  When this happens, the program should stop.

    Concepts Required:  input/output, decision making, loops, addition, subtraction

  5. A young man agrees to work for a company at the very modest salary of a penny a week, with the stipulation that his salary will double each week. What is his week’s salary at the end of six months and how much has he earned during those first six months?

    Concepts Required:  output, looping, counters, addition

  6. A number is to be typed.  If the typed number is between 7 and 35 inclusive, display BETWEEN.  If the number is less than 7, increase it by 5; if the number is greater than 35, decrease it by 5.  In either case, display the new value and check again to see whether the value is now between 7 and 35.  repeat this process until BETWEEN is displayed.

    Concepts Required:  input/output, loops decision, addition, subtraction

  7. Write a program that will ask the user to input a number. Repeat this until the sum of the numbers entered is greater than 100 or the user enters “Quit”. Display the sum before quitting.Concepts Required:  input/output, loops, decision, addition

As you complete each exercise, please submit it with the appropriate file name using this submission link.  Submit all Set 1 exercises using this link.