What is OOP?
Programming using classes and objects.
Surrrrrrrrrrrrrrrrrprrrrrrrriseeeeeeeeeee
Minus
Which structure does not allow duplicates?
Set
x = 10
print(x)
10
class Cat
pass
missing :
What is the difference between Class and Object?
Class → blueprint
Object → instance of the class
Which method runs automatically when creating an object?
__init__
Surprrrrrrrrrrrrrrrrrrrriseeeeee
Bounes
numbers = [1,2,3]
numbers.append(4)
print(numbers)
[1,2,3,4]
numbers = (1,2,3)
numbers.append(4)
Tuple cannot use append
Name 3 pillars of OOP.
Inheritance
Encapsulation
Polymorphism
(+ Abstraction)
What does self represent?
The current object.
Which structure is ordered but immutable?
Tuple
for i in range(3):
print(i)
0
1
2
if x = 5:
print("yes")
Should be ==
What is Inheritance?
When a class inherits properties and methods from another class.
What function is used to get the length of a list?
len()
Which data structure is best for storing multiple students?
List
class Car:
def __init__(brand):
self.brand = brand
Missing self
What is Method Overriding?
When a child class redefines a method from the parent class.
What keyword is used to create a function in Python?
def
Which structure allows fast membership checking and no duplicates?
Set
class Animal:
def speak(self):
print("Animal sound")
class Dog(Animal):
def speak(self):
print("Bark")
d = Dog()
d.speak()
Bark
class Student:
def __init__(self,name):
name = name
The attribute is not assigned to the object.