Input, Output and Type Conversion · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Ask, convert, print

Computing · Programming · ages 14-15
Name ______________________   Date ____________
  1. What is the value of int('34') + 56?

    • 90
    • '3456'
    • An error pops up
  2. What does input() hand your program?

    • A whole number
    • Text the user typed
    • A decimal number
  3. print() shows a value on the screen.

    Circle one:   True   False

  4. What is the value of '50' * 3?

    • 150
    • An error pops up
    • '505050'
  5. A shop program reads quantity 3 and price 5.0, then prints quantity times price. What prints?

    • 15
    • 15.0
    • '35'
  6. Why does 8 * 0.25 print as 2.0 and not 2?

    • A whole number times a decimal gives a decimal
    • The computer rounds every answer up
    • print() adds a point to whole numbers
  7. A program runs n = int(input()). The user types 8. It prints n times 1.5. What prints?

    Answer: ______________

  8. A program asks for two numbers and prints their sum, but 4 and 7 print as 47. What is the fix?

    • Ask for the numbers twice
    • Swap print() for input()
    • Convert both inputs with int() before adding
LightMySky · lightmysky.comW1-mt_lZmkGSELbC-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Ask, convert, print W1-mt_lZmkGSELbC-s1

  1. 90 · int('34') becomes the number 34, and 34 + 56 is 90.
  2. Text the user typed · input() always returns text, even when the user types digits.
  3. True · print() outputs values so the user can see them.
  4. '505050' · A string times a whole number repeats the text three times.
  5. 15.0 · A whole number times a decimal gives a decimal, printed with a point.
  6. A whole number times a decimal gives a decimal · Mixing a whole number with a decimal always produces a decimal.
  7. 12 · The text becomes the number 8, and 8 times 1.5 is 12.
  8. Convert both inputs with int() before adding · The inputs were added as text. Converting them first gives 11.
Worksheet · LightMySky