Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    PyPython

    Getting started

    • Your first Python program
    • Variables and types
    • Numbers and operators
    • Type conversion and input

    Strings

    • Strings and f-strings
    • String indexing and slicing
    • Cleaning and splitting strings

    Control flow

    • Conditions: if, elif and else
    • Loops: for and while
    • Loop control and nesting

    Functions

    • Functions with def
    • Parameters and scope

    Collections

    • Lists
    • Dictionaries
    • Tuples and sets
    • Comprehensions, enumerate and zip

    Errors, files and libraries

    • Handling exceptions
    • Modules and the standard library
    • Reading and writing files
    • Exchanging data with JSON

    Objects and lazy iteration

    • Classes and objects
    • Inheritance and composition
    • Iterators and generators

    Testing and project

    • Testing and project setup
    • Project: a grade report
    Python

    Getting started · Lesson 2 of 25

    Variables and types

    Store values and check their type with type().

    8 minutes3 games

    Python needs no let and no type: write a name, = and a value. The basic types:

    • int: whole number, 19.
    • float: decimal, 1.65.
    • str: text, "Huda".
    • bool: True or False (capitalised).
    • None: “no value”.
    name"Huda"str
    age19int
    height1.65float
    is_studentTruebool
    Python
    name = "Huda"
    age = 19
    height = 1.65
    is_student = True
    phone = None
    
    print(name, age)
    print(type(age), type(height), type(name), type(is_student), type(phone))
    
    x, y = 3, 7    # two at once
    x, y = y, x    # swap
    print(x, y)
    Step by step1 / 4
    1. ▶score = 10
    2. 2score = score + 5
    3. 3score += 1
    4. 4print(score)

    Variables

    score10

    Output

    …

    Python names use snake_case: lowercase with _ between words, user_name, total_price. Constants are uppercase: MAX_SIZE = 100.

    Important

    Python is dynamically typed: the same variable can later hold another type (x = 5, then x = "five"). It's allowed, but avoid it; it confuses readers.

    Interview question

    What's the difference between mutable and immutable in Python? Give examples.

    Complete the code

    Complete: create city with the value Alex and print it.

    city  "Alex"
    (city)

    What's the output?

    a, b = 1, 2
    a, b = b, a
    print(a, b)

    What will this code print?

    Exercise

    Make a = 7 and b = 3, and print their product.

    Expected output: 21

    Python

    Learn more from

    • Python docs: Built-in Typesdocs.python.org
    • PEP 8: Naming Conventionspeps.python.org
    • Real Python: Variables in Pythonrealpython.com

    Played 0 of 3 games

    Sign in to save your progress and earn XP.

    PreviousYour first Python programNextNumbers and operators
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.