CS21: Quiz 1 Topics

You should understand the following terms:

You should be able to use the following Python concepts and functions:

Sample practice problems:

  1. Show the output from the following code fragments:
    for i in range(4):
       print(i)
       print("-----")
    for x in range(6):
       print("x =",x)
    print("done!")
    for ch in "hello!":
       print("---" + ch + "---")
  2. Write a program to convert a certain number of gallons (entered by the user) to liters. There are 3.79 liters in a gallon.
    $ python3 gallons.py
    Gallons: 2
    That's 7.58 liters.
    
  3. Write a program that asks the user for their name, and then prints their name 20 times.

  4. What is the value and type for each of the following expressions? Try them in python3 to check your answers.

For example, the answer to the first one (2 + 3) would be: value=5, type=integer.