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

    Testing and project · Lesson 25 of 25

    Project: a grade report

    Use everything you learned in a small real program.

    10 minutes1 games

    You have student marks in a dictionary. Write a program that prints each student's mark and grade, then the average and the top student. You'll use a dictionary, for, if, a function and f-strings.

    Python
    marks = {"Ali": 88, "Mona": 95, "Omar": 72, "Sara": 64}
    
    def grade(m):
        if m >= 85:
            return "A"
        elif m >= 70:
            return "B"
        return "C"
    
    for name, m in marks.items():
        print(f"{name}: {m} ({grade(m)})")
    
    average = sum(marks.values()) / len(marks)
    best = max(marks, key=marks.get)
    print(f"Average: {average:.1f}")
    print(f"Top student: {best}")

    Important

    Check that the dictionary is nonempty before calculating an average. Define how ties are handled when choosing the top student.

    Interview question

    How do you separate computation from presentation?

    Student scores

    Validate data

    Compute grades

    Display report

    {average:.1f} prints the number with one decimal place.

    Exercise

    Print how many students passed (60 or more). The result is 3.

    Expected output: 3

    Python
    marks = {"Ali": 88, "Mona": 95, "Omar": 52, "Sara": 64}
    

    Learn more from

    • Python documentationdocs.python.org
    • Real Python: further readingrealpython.com

    Played 0 of 1 games

    Sign in to save your progress and earn XP.

    PreviousTesting and project setup🎉 خلّصت Python!
    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.