liveBook · Manning

Python

As explained in Python Workout: 50 ten-minute exercises

Python 3 is the major version of the Python programming language in which input returns text entered by the user.

Python 3 is used to turn user input into useful results, combining strings, numeric types, loops, conversions, and formatted output. A recurring pattern is to read values, transform them, accumulate information, and report the result. section 1.22 section 10.27

Work through input-driven programs by:

  • Converting input strings with int or float when calculations or comparisons require numeric values. section 1.3 section 1.22
  • Repeating input with a loop, stopping when the user submits an empty response, and accumulating values for a final report. section 1.12 section 1.3
  • Using f-strings to place computed values into readable output. section 1.3

Average ten-kilometre run times

A small Python program can collect floating-point times until Enter ends the loop, then display their average: `times = []\nwhile True:\n value = input('Enter 10 km run time: ')\n if not value:\n break\n times.append(float(value))\nprint(f'Average: {sum(times) / len(times)}')`. This exercise makes type conversion and accumulation visible while producing a practical report. section 1.12 section 1.3

Enter 10 km run time: 15
Enter 10 km run time: 20
Enter 10 km run time: 10
Enter 10 km run time: <enter>

Average of 15.0, over 3 runs

The sample interaction shows repeated numeric input, an empty response as the stopping signal, and the resulting average. section 1.12

How Python Workout: 50 ten-minute exercises covers it

How deep it goes
Demonstrates conversions, loops, accumulation, comparisons, and formatting through exercises, while stopping short of language internals.
Examples
Uses a run-timing average, a number-guessing interaction, and contrasting assignment forms inside input loops.
What it assumes
Assumes familiarity with basic programming while reinforcing Python’s type distinctions and conversion rules.
What you can do after
Apply Python to break problems down, choose constructs, compare trade-offs, and write readable, Pythonic solutions.
How it connects
Connects Python with strings, integers, floating-point numbers, loops, type conversion, input handling, and f-strings.

Also explained in

Compare how 26 books explain Python →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Workout: 50 ten-minute exercises. The section links point to the parts of the book it draws on.