Data Types & Type Conversion Exercises

  1. What is the output of the following code:
    favoriteColorLancelot = "blue"
    print("Lancelot's favorite color:", favoriteColorLancelot)
    print("Type:", type(favoriteColorLancelot))
    
    age = 25
    print("age's value:", age)
    print("age's type:", type(age))
    
    age = input("Enter your age: ")
    print("age's type:", type(age))
    
    age = int(age)
    print("age's value:", age)
    print("age's type:", type(age))
    
    grade = input("Please enter your grade: ")
    print("grade's value:", grade)
    print("grade's type:", type(grade))
    
    grade = float(grade)
    print("grade's value:", grade)
    print("grade's type:", type(grade))
    
  2. Describe to your neighbor how int() works. Include:
    • A general description
    • What it takes as an argument
    • What it returns
    • Any limitations
  3. Describe to your neighbor how float() and str() work. Include:
    • A general description for each
    • What each one takes as an argument
    • What each one returns
    • Any limitations for each function