To see how to create a class and object in python3.
A class is simply a blueprint of a data that defines the characteristics and behavior of its data members.
Python starts with the keyword class followed by the name of the class and colon(:)Eg.class student():
The body of the class which contains variables, data, and functions.
Object is memory reference of a class.
Used to store data and functions defined inside a class.
Using object we can call the methods that are defined in the class.
Object should be within the class not with in the methods
def __init__ (self,n , m =0 ):
self.name = n
self.marks = m
print(“your marks”, self.marks)
if (self.marks >= 75):
print(“you got first class”)
elif (self.marks >= 45):
print(“you are pass”)
print(“you are fail”)
#get input from the user
n = int(input(“how many students marks:” ))
#initialize the loop for many students
i = 0
while (i < n):
name = input(“enter the name : “)
marks = int(input(“enter the marks: “))
#object creation for student class
#method calling statements