Extra Exercises

  1. Write code that asks the user to enter a numeric score (0-100). In response, it should print out the score and corresponding letter grade, according to the table below.

    Score Grade
    >= 90 A
    [80-90) B
    [70-80) C
    [60-70) D
    < 60 F

    The square and round brackets denote closed and open intervals. A closed interval includes the number, and open interval excludes it. So 79.99999 gets grade C , but 80 gets grade B.

  2. A year is a leap year if it is divisible by 4, unless it is a century that is not divisible by 400. Write code that asks the user to input a year and output True if it’s a leap year, or False otherwise. Use if statements.

    Here are some examples of what the output should be for various inputs.

    Year Leap?
    1944 True
    2011 False
    1986 False
    1800 False
    1900 False
    2000 True
    2056 True
Next Section - Introduction: Working with Data Files