Item 1
Object-Oriented Programming (OOP)
OOP organizes code into classes and objects. A class is a blueprint; an object is an instance of that class with its own attributes (data) and methods (functions).
Try it — edit the code and press Run:
Lesson 5
Item 1
OOP organizes code into classes and objects. A class is a blueprint; an object is an instance of that class with its own attributes (data) and methods (functions).
Try it — edit the code and press Run:
Item 2
Functional programming builds programs from small functions. Tools like lambda, map() and filter() apply functions to data.
Try it — edit the code and press Run:
Item 3
Real software combines input, decisions, loops, data structures and functions into one organized program — often with a menu the user can interact with.
Try it — edit the code and press Run:
Item 4
Syntax errors break the grammar rules (missing colon or bracket). Runtime errors happen while running, like NameError, TypeError and ZeroDivisionError. Logical errors give wrong results without any message.
Try it — edit the code and press Run:
1. What is a class?
2. What error does print(x) give if x is not defined?
3. Why does 5 + "5" cause an error?
4. Which error gives a wrong result with no message?
5. What does map() do?
Auto-checked exercises at three levels. Open hints one by one before the solution.
This code has a NameError. Fix it so it prints: Welcome Sara
Use try/except to print 10 / 0. If it fails print "Error".
Create class Car with attribute brand and method info() that prints "Car: <brand>". Create Car("BMW") and call info().
Goal: Combine everything into one interactive program.
Requirement: Build a menu: 1) Add student 2) Show all students with grades 3) Exit. Use a list of dictionaries, functions, loops and try/except for invalid input.