Table of Contents
Python program to create class and objects
Python program to create class and objects : implement object oriented concepts of class, object and constructor in python, class and objects are used to hold the data members.
program to create class and objects in python
class Student:
def __init__(self, name, id, age, course, city):
self.name = name
self.id = id
self.age = age
self.course = course
self.city = city
def display(self):
print("Name : ",self.name,"nID : ",self.id,"nAge : ",self.age,"nCourse : ",self.course,"nCity : ",self.city)
s = Student("Gaurav","002","26","BCom","Thane")
s.display()
Output :
Name : Gaurav
ID : 002
Age : 26
Course : BCom
City : Thane
We are aiming to explain all concepts of python in easiest terms as possible.

ITVoyagers
Author
PRACTICALS/PRACTICE PROGRAM IN PYTHON
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
Quizzes on File Handling |
Easy quiz on file handling in python part 1 |
Easy quiz on file handling in python part 2 |
Quizzes on Exception Handling |
Easy quiz on Exception Handling in python part 1 |
Easy Quiz on Exception Handling in python part 2 |
Quizzes on Regular Expressions |
Easy Quiz on Regular Expression in python part 1 |
Quizzes on Python concepts coming soon… |
Python basic quiz |
New and easy python quiz basic part 1 |
New and easy python quiz (basic) part 2 |
New and easy python quiz (basic) part 3 |
Python practice quiz set |
Best Practice Quiz Set on Python Programming Part 1 |
Best Practice Quiz Set on Python Programming Part 2 |
Best Practice Quiz Set on Python Programming Part 3 |
Best Practice Quiz Set on Python Programming Part 4 |
Best Practice Quiz Set on Python Programming Part 5 |