0% found this document useful (0 votes)
3 views3 pages

Python Programming Lab 4

Uploaded by

vishnupriyapacet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Python Programming Lab 4

Uploaded by

vishnupriyapacet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 3

4(a):Implementing real-time/technical applications using

Sets, Dictionaries. (Student Enrolment and Mark sheet -


operations of Sets & Dictionaries

OPERATIONS ON DICTIONARIES

enroll={"Name":"abcd","PhoneNo":"123456","DOB":"1.1.11"}
print(enroll)
a=enroll.copy()
print(a)
a=enroll.get("Name")
print("Name of the student is:",a)
a=enroll.items()
print("Items in Dictionary:",a)
a=enroll.values()
print("Values in Dictionary:",a)
b="of the student"
thisdict=dict.fromkeys(enroll,b)
print("After creating Dictionary from Key & values:",thisdict)
a=enroll.keys()
print("List of Keys:",a)
enroll.clear()
print(enroll)

Output

{'Name': 'abcd', 'PhoneNo': '123456', 'DOB': '1.1.11'}


{'Name': 'abcd', 'PhoneNo': '123456', 'DOB': '1.1.11'}
Name of the student is: abcd
Items in Dictionary: dict_items([('Name', 'abcd'), ('PhoneNo',
'123456'), ('DOB', '1.1.11')])
Values in Dictionary: dict_values(['abcd', '123456', '1.1.11'])
After creating Dictionary from Key & values: {'Name': 'of the
student', 'PhoneNo': 'of the student', 'DOB': 'of the student'}
List of Keys: dict_keys(['Name', 'PhoneNo', 'DOB'])
{}

4(b):Implementing real-time/technical applications


using Sets, Dictionaries. (Student Enrolment and Mark
sheet - operations of Sets & Dictionaries)

OPERATIONS ON SETS

marksheet1=set(("Name","Register Number","Marks"))
marksheet2=set(("Name","Phone Number","DOB"))
print("Marksheet1:",marksheet1)
print("Marksheet2:",marksheet2)
marksheet1.add("College Name")
print("After adding item:",marksheet1)
marksheet2.remove("Phone Number")
print("After Removing:",marksheet2)
m3=marksheet1.intersection(marksheet2)
print("Intersection of Marksheet1 and Marksheet2 is:",m3)
m4=marksheet1.difference(marksheet2)
print("Difference between Marksheet1 & Marksheet2 is:",m4)
Output

Marksheet1: {'Name', 'Marks', 'Register Number'}


Marksheet2: {'Phone Number', 'DOB', 'Name'}
After adding item: {'College Name', 'Name', 'Marks', 'Register
Number'}
After Removing: {'DOB', 'Name'}
Intersection of Marksheet1 and Marksheet2 is: {'Name'}
Difference between Marksheet1 & Marksheet2 is: {'College
Name', 'Register Number', 'Marks'}

You might also like