OOP
Python Basics
Data Structures
Code Reading(what is the output)
Debugging
100

What is OOP?

Programming using classes and objects.

100

Surrrrrrrrrrrrrrrrrprrrrrrrriseeeeeeeeeee

Minus

100

Which structure does not allow duplicates?


Set

100

x = 10

print(x)

10

100

class Cat

    pass

missing :

200

What is the difference between Class and Object?


Class → blueprint
Object → instance of the class

200

Which method runs automatically when creating an object?


__init__

200

Surprrrrrrrrrrrrrrrrrrrriseeeeee

Bounes

200

numbers = [1,2,3]

numbers.append(4)

print(numbers)

[1,2,3,4]

200

numbers = (1,2,3)

numbers.append(4)

Tuple cannot use append

300

Name 3 pillars of OOP.


  • Inheritance

  • Encapsulation

  • Polymorphism
    (+ Abstraction)

300

What does self represent?


The current object.

300

Which structure is ordered but immutable?


Tuple

300

for i in range(3):

    print(i)

0
1
2

300

if x = 5:

    print("yes")

 Should be ==

400

What is Inheritance?


When a class inherits properties and methods from another class.

400

What function is used to get the length of a list?


len()

400

Which data structure is best for storing multiple students?


List

400

class Student:

    def __init__(self,name):

        self.name = name


s1 = Student("Ali")

s2 = Student("Sara")


print(s1.name)

print(s2.name)

Ali
Sara

400

class Car:

    def __init__(brand):

        self.brand = brand

Missing self


500

What is Method Overriding?


When a child class redefines a method from the parent class.

500

What keyword is used to create a function in Python?


def

500

Which structure allows fast membership checking and no duplicates?


Set

500

class Animal:

    def speak(self):

        print("Animal sound")


class Dog(Animal):

    def speak(self):

        print("Bark")


d = Dog()

d.speak()

Bark

500

class Student:

    def __init__(self,name):

        name = name

The attribute is not assigned to the object.


M
e
n
u