Wrap-up and practice

Basic python

Wrap-up and practice

So far you’ve covered:

  • How to run Python in the REPL and via scripts
  • Numbers (integers and floats) and the key operators
  • Assigning values to variables and choosing names
  • Working with strings plus print / input

Combining these pieces already lets you build meaningful mini-programs. The more you experiment, the deeper your understanding becomes.

Challenge 1: Temperature converter #

Create a program that converts Fahrenheit to Celsius using C = (F - 32) * 5 / 9.

Enter Fahrenheit: 77
25.0 °C

input returns a string, so convert it before calculating. Use round() if you want to limit decimal places.

Challenge 2: Alarm clock #

Ask for the current time (hour and minute, 24-hour format) and how many minutes until the alarm should ring, then display the alarm time.

Current hour (0-23): 21
Current minute (0-59): 30
Alarm in how many minutes? 90

Alarm time: 23:00

To stay within 24 hours, take the total minutes and use the remainder of dividing by 24 * 60.

Challenge 3: Simple budget tracker (extended) #

Gather expenses for each day of a week, then display the total and the average. Start with plain variables, then refactor with lists or loops if you can.

Monday expense: 1200
Tuesday expense: 980
...
Total: xxxx yen
Average: xxxx yen

Whenever you see repeated patterns, consider how the loops you’ll learn next could simplify the code.

Common stumbling blocks #

IssueCause & remedy
NameError: name 'value' is not definedThe variable is used before assignment or has a typo. Check your ordering and spelling.
ValueError: invalid literal for int()The string you convert with int() contains non-numeric characters. Validate the input or handle the exception (covered later).
TypeError when concatenating stringsYou tried to combine numbers and strings with +. Use f-strings or str() to convert numbers first.

You’ve completed “01 Python Basic Syntax”. Next up: conditionals and loops for more dynamic programs. Take a break, then revisit any sections you’d like to reinforce by coding again.