Software Development free courses

Master the TrickFoundationFree

Python Programming Foundations

Practice Python values, loops and small functions with predictable inputs and simple tests.

3 reading lessons · about 30 min ·written by MTT

The idea

Python values have types, including integers, floats, strings, booleans and lists. A variable name refers to a value, and assigning a new value can change that reference. Input read from a user is commonly text and needs explicit validation before numeric calculation. Type conversion can fail; handle invalid input rather than assuming every string contains a valid number.

Worked example

The expression 10 + 5 gives 15, while '10' + '5' gives the string '105'. The list prices = [10, 20, 30] holds three ordered values; prices[0] is 10 because indexing starts at zero. Trying to read prices[3] fails because the fourth element does not exist.

Try it

Write down the types and results of 2 + 3, '2' + '3' and int('2') + 3. Create a three-item list and identify its first and last valid indexes. Explain what should happen if someone types a word where your program expects a whole-number quantity.

Lesson 1 of 3 · About 10 min

Start with values and types

Check your understanding

Course quiz

Finish the course to unlock the quiz

Complete all 3 lessons and 5 questions open up here. You have 3 to go.

What you will learn

  • Distinguish strings, numbers and lists
  • Trace a loop and conditional
  • Define a function and check edge cases

Before you start

Prerequisites
None. A local Python 3 installation is optional; examples can be traced on paper.
Cost
Free introductory reading lessons, exercises and quiz. Optional third-party tools, hosting or AI subscriptions may cost money.

Original introductory lessons and assessment by Master the Trick. Estimated times include the suggested exercises.