Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Dictionary Example and Class Definition - Python Programming

Rating
-
Sold
-
Pages
2
Uploaded on
07-05-2026
Written in
2025/2026

Provides Dictionary Example and Class Definition in python programming along with suited syntaxes with easy explanation

Institution
Course

Content preview

PYTHON NOTES JEGAN K K

COLLEGE AND STUDENTS LIST USING DICTIONARY AND CLASS
clgdict = dict()
class College (clg):
NameList = []
def Student (stu):
NameList.append(stu)
clgdict[clg] = NameList
return Student
clg1 = College('ABC College')
clg2 = College('XYZ College')
clg1('Jegan')
clg1('A')
clg2('Hari')
clg2('B')
In the above example, outer class college receives the college name and is created as a
reference. The Inner class parameter is passed with outer class reference. So the names of
student called with respective college instance gets appended to the list (i.e. NameList), thus
maintaining the student record for each college respectively.

NOTE: Even if class college is deleted, the reference works.

CLASS:
Class is a blueprint or a prototype that is set initially to create instance with it and can be used
later. The previous example is a class with a sub-class defined within.

Syntax:
class Class_name:
def __init__(self):
print ('A Reference Instantiated')
In the above example, a class is instantiated or created along with a method which is called the
default constructor, 2 underscores followed by 'init' followed by 2 underscores again. It runs by
default when a reference is initiated. The syntax to initiate is given below,

Syntax: cls_ref = class_name()

We can also send default parameter while initiating a reference inside the '()' which is followed
after class_name. It is sent as a parameter to the default constructor __init__(). We should
define the default constructor in such a way that it receives a parameter and for initiating it we
use the self keyword (self.parameter = parameter).

Written for

Course

Document information

Uploaded on
May 7, 2026
Number of pages
2
Written in
2025/2026
Type
Class notes
Professor(s)
Jegan k k
Contains
Dictionary and class concepts

Subjects

$3.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
jegan

Get to know the seller

Seller avatar
jegan Self Employed
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 month
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions