Code Playground
Free space to write and run Python
Write Python in your browser and run it with a real Python interpreter. Try changing the student name, or use input() and a virtual class-notes file.
student = "Mira"
marks = [82, 91, 76]
print(f"{student}'s average mark is {sum(marks) / len(marks):.1f}")
name = input("What is your name? ")
print("Welcome,", name)
with open("class_notes.txt", "r") as notes:
print(notes.read())Output
Your program's output will appear here.
Common Python mistakes
NameError: name 'mark' is not defined
NameError: A name was used before Python could find a variable or function with that name.
IndexError: list index out of range
IndexError: The requested position is outside the items in this list or sequence.
KeyError: 'email'
KeyError: That key does not exist in this dictionary.
TypeError: can only concatenate str (not "int") to str
TypeError: This operation does not work with the kind of value it received.
ZeroDivisionError: division by zero
ZeroDivisionError: A number cannot be divided by zero.
SyntaxError: invalid syntax
SyntaxError: Python could not understand the structure of this line. Check spelling, brackets, colons, and quotes.
IndentationError: expected an indented block
IndentationError: The spaces at the start of a line do not match Python's block structure.
- Experiment freely with any code
- Standalone editor
Interactive lesson content for this topic is planned for a later phase.