Python Basics for Beginners

Learn core programming concepts through hands-on Python exercises

beginner36 min18 cards
  • Set up a Python environment and run basic scripts
  • Declare variables and use core data types
  • Write programs using conditionals, loops, and functions

Swipe up to begin ↑

ConceptIntroduction to Python

Why Python?

Python's Advantages

Python is a high-level, interpreted language popular for its readable syntax and broad applications in web development, data analysis, automation, AI, and scripting.

  • Easy to learn and read
  • Extensive standard library
  • Cross-platform compatibility
  • Strong community support
CheckIntroduction to Python

Advantages Check

Which feature makes Python especially suitable for beginners?

Try itIntroduction to Python

Hello World Simulator

Interact with a virtual Python REPL: type print("Hello, World!") or other basic print statements, press Run, and observe the exact console output. Supports simple string experiments only.

Hello, World!
RecallIntroduction to Python
What are the two main steps to set up Python and run your first script?
ConceptVariables and Data Types

What is a Variable?

A variable stores a value under a name. Assign with =.

name = "Alex"
score = 95

ConceptVariables and Data Types

Basic Data Types

Four core types:

  • int: whole numbers (42)
  • float: decimals (3.14)
  • str: text ("hello")
  • bool: True/False
CheckVariables and Data Types

Type Check

What type is the value 42?

Try itVariables and Data Types

Assign & Inspect

Interactive widget: learner types a variable name and value (e.g. age=25 or active=True), clicks assign, then sees the stored value and its type displayed. Maintains a live list of all assigned variables that updates with each new assignment.

Widget initialized. No variables assigned.
RecallVariables and Data Types
Write code to store the boolean True in a variable called is_ready.
ConceptControl Flow

If/Else Decisions

Conditional Execution

Use if statements to run code only when a condition is true. Add else (or elif) for alternative paths.

if x > 0:
print("positive")
else:
print("non-positive")

CheckControl Flow

If/Else Check

What runs when the if condition is false and an else clause exists?

Try itControl Flow

For Loop Explorer

Select start and end integers. The applet simulates a for-loop over range(start, end), displays each iteration value, and shows the final accumulated result.

{"start":1,"end":5}
RecallControl Flow
Basic while loop syntax
CheckControl Flow

Loop Choice

Which loop is best when the number of repetitions is not known in advance?

ConceptFunctions

Defining Functions

Defining a Function

Functions organize code into reusable blocks using the def keyword.

  • Start with def function_name():
  • Indent the body
  • Call later with function_name()
CheckFunctions

Syntax Check

Which defines a valid function?

Try itFunctions

Function Builder

Interactive simulator: type a function definition (e.g. def greet(name): return 'Hi '+name), then enter arguments to call it and view the printed result or error. Supports editing, calling multiple times, and resetting.

Ready for function definition.
RecallFunctions
How do you pass an argument and return a value?