Function to calculate student grade Dry Run in PYTHON

Function to calculate student grade is an interactive PYTHON dry run visualizer from the Functions programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Function to calculate student grade Program Code

def calculate_grade(marks):
    """Return grade based on marks"""
    if marks >= 90:
        return 'A'
    elif marks >= 80:
        return 'B'
    elif marks >= 70:
        return 'C'
    elif marks >= 60:
        return 'D'
    else:
        return 'F'

students = [("Alice", 95), ("Bob", 82), ("Charlie", 67)]
for name, score in students:
    grade = calculate_grade(score)
    print(f"{name}: {score} → Grade {grade}")

View the complete Functions programs page.

Program Console Function to calculate student grade Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.