Python Basics: Interactive Python Lessons

Start from zero: variables, data types, input and output, and your very first print statement. These interactive Python basics exercises give you instant feedback as you write real code in the browser.

54 lessons in this topic — 9 free to start. Every lesson runs real Python in your browser with instant feedback.

beginnerFree

Hello Python World

Learn to print your first message in Python

beginnerFree

Variables and Numbers

Store and use numbers in variables

beginnerFree

Simple Math Operations in Python

Learn how to perform basic math operations using Python.

beginnerFree

String Fun

Work with text in Python

beginnerFree

Print Multiple Lines

Learn to print multiple messages

beginnerFree

Numbers and Math

Work with different numbers

beginnerFree

Subtraction Fun

Practice subtraction in Python

beginnerFree

Multiplication Magic

Multiply numbers together

beginnerFree

Division Basics

Divide numbers in Python

beginner

Comments in Code

Add comments to explain code

beginner

Variable Names

Learn good variable naming

beginner

Number Comparison

Compare numbers with operators

beginner

Boolean Values

Work with True and False

beginner

Multiple Variables

Create several variables at once

beginner

Modulo Operator

Find remainders with modulo

beginner

Power Operator

Learn how to use the power operator (**) to calculate exponents in Python.

beginner

Integer Division

Divide without decimals

beginner

Greet Ada

Print exactly: Hi Ada, welcome to Python!

beginner

Negative Indexing

Access items from the end

beginner

Type Conversion - String to Int

Convert text to numbers

beginner

Type Conversion - Int to String

Convert numbers to text

beginner

Is 14 even or odd?

Print 'even' if 14 is even, else 'odd'.

beginner

Absolute Value

Get positive version of numbers

beginner

Round Function

Round decimal numbers

beginner

Logical AND

Combine conditions with AND

beginner

Is 14 greater than 3?

Print whether 14 > 3 (True or False).

beginner

Logical OR

Combine conditions with OR

beginner

Logical NOT

Invert boolean values

beginner

In Operator

Check if item exists

beginner

Using the "not in" Operator

Check if an item does not exist in a list or string using the "not in" operator.

beginner

Identity Operator

Check if variables are same object

beginner

Add 3 to the text "14"

14 is a string. Convert it to a number, add 3, print the result.

beginner

Remainder of 14 ÷ 3

Print the remainder of 14 divided by 3 using %.

beginner

Greet Sam

Print exactly: Hi Sam, welcome to coding!

beginner

Is 7 even or odd?

Print 'even' if 7 is even, else 'odd'.

beginner

Is 7 greater than 5?

Print whether 7 > 5 (True or False).

beginner

Add 5 to the text "7"

7 is a string. Convert it to a number, add 5, print the result.

beginner

Remainder of 7 ÷ 5

Print the remainder of 7 divided by 5 using %.

beginner

Greet Mia

Print exactly: Hi Mia, welcome to Python!

beginner

Is 40 even or odd?

Print 'even' if 40 is even, else 'odd'.

beginner

Is 40 greater than 6?

Print whether 40 > 6 (True or False).

beginner

Add 6 to the text "40"

40 is a string. Convert it to a number, add 6, print the result.

beginner

Remainder of 40 ÷ 6

Print the remainder of 40 divided by 6 using %.

beginner

Greet Leo

Print exactly: Hi Leo, welcome to programming!

beginner

Is 42 even or odd?

Print 'even' if 42 is even, else 'odd'.

beginner

Is 42 greater than 8?

Print whether 42 > 8 (True or False).

beginner

Add 8 to the text "42"

42 is a string. Convert it to a number, add 8, print the result.

beginner

Remainder of 42 ÷ 8

Print the remainder of 42 divided by 8 using %.

beginner

Greet Noa

Print exactly: Hi Noa, welcome to Python!

beginner

Is 100 even or odd?

Print 'even' if 100 is even, else 'odd'.

beginner

Is 100 greater than 7?

Print whether 100 > 7 (True or False).

beginner

Add 7 to the text "100"

100 is a string. Convert it to a number, add 7, print the result.

beginner

Remainder of 100 ÷ 7

Print the remainder of 100 divided by 7 using %.

beginner

Greet Eli

Print exactly: Hi Eli, welcome to coding!