First Summer 2006


Lab Five: Paths, branches and conditional execution statements in Python.
Here is the lab assignment for today, which needs to be turned in in Oncourse tonight:

8. Write a program (called Eight)

  • that translates a number between 0 and 4
  • into the closest letter grade.

For example,

  • the number 2.8 (which might have been the average of several grades)
  • would be converted to B-.

Break ties in favor of the better grade; for example 2.85 should be a B.

Here's a sample run of such a program:
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : 3.85
A
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : 3.84
A-
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : 3.5
A-
frilled.cs.indiana.edu%java Eight

Enter numeric score then press Enter : 3.49
B+
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : 3.1
B
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : 10

A+
frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : -2

frilled.cs.indiana.edu%java Eight
Enter numeric score then press Enter : -0.5

frilled.cs.indiana.edu%

You, of course, need to write a program in Python.

Before you work out this problem here are some questions, for your warm-up.

These questions are good practice, yet you don't need to turn them in:

  1. Write a program that asks for a positive number.

    If the number you enter is positive the program asks for a second number, otherwise it ends.

  2. Write a program that reads a positive integer and reports if the number entered is divisible by 19 or not.

  3. Write a program that

    If the number does not match the program prints "sorry".

  4. Write a program that generates a random integer between -50 and 50 every time you call it.

  5. Write a program that starts from the string "123" and adds its digits to produce 6.

  6. Write a program that

  7. Write a program that


Last updated: May 16, 2006 by Adrian German for A201/A597