Computer Science I / Input, Output, and File Thinking
Practice question · Put in order

Order the steps a program takes to read a number from the user and add ten to it.

Hints
  1. The conversion must happen before any arithmetic, because the input is text.
  2. Adding before converting would try to add to a string.
Show the answer
  1. Prompt the user to type a number
  2. Read the input, which arrives as a string
  3. Convert the string to an integer with int(...)
  4. Add ten to the integer
  5. Print the result
Why

Prompt, read text, convert to a number, then compute, then print. Doing the arithmetic before the conversion is the classic failure, it either joins strings or raises an error, because the input is text until int(...) turns it into a number.

Read the lesson: Input, Output, and File Thinking →

Practise Input, Output, and File Thinking

The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Input, Output, and File Thinking