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 3 of 25

    Numbers and operators

    True and floor division, remainder, powers and round.

    7 minutes3 games
    OperatorMeaningExample

    /

    true division (always float)

    7 / 2 → 3.5

    //

    floor division

    7 // 2 → 3

    %

    remainder

    7 % 2 → 1

    **

    power

    2 ** 10 → 1024

    abs() / round()

    absolute value / rounding

    round(3.14159, 2) → 3.14

    Python
    print(7 / 2, 7 // 2, 7 % 2, 2 ** 10)
    print(round(3.14159, 2), abs(-8), max(4, 9, 2), min(4, 9, 2))
    
    import math
    print(math.sqrt(81), math.floor(4.7), math.ceil(4.2), math.pi)
    
    print(10 / 3)
    print(f"{10 / 3:.2f}")
    print(1_000_000 + 1)

    Use _ inside big numbers to read them easily: 1_000_000 is a million.

    Important

    Python's round goes to the even number on an exact half (banker's rounding): round(2.5) is 2 and round(3.5) is 4. It reduces bias in large calculations.

    Interview question

    What's the difference between / and // in Python 3?

    What's the output?

    print(17 // 5, 17 % 5)

    What will this code print?

    What's the output?

    print(6 / 2)

    What will this code print?

    Exercise

    You have 125 minutes. Print hours and remaining minutes as 2 h 5 min.

    Expected output: 2 h 5 min

    Python
    minutes = 125
    

    Learn more from

    • Python docs: Numeric Typesdocs.python.org
    • Python docs: math moduledocs.python.org
    • Real Python: Numbers in Pythonrealpython.com

    Played 0 of 3 games

    Sign in to save your progress and earn XP.

    PreviousVariables and typesNextType conversion and input
    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.