Python Exp14,15,16
Python Exp14,15,16
14.1)
14.2)
14.3) Write a Python program to create a class 'Degree' having a method 'getDegree' that prints
"I got a degree". It has two subclasses namely 'Undergraduate' and 'Postgraduate' each having
a method with the same name that prints "I am an Undergraduate" and "I am a Postgraduate"
respectively. Call the method by creating an object of each of the three classes.
details.py:-
import socket
import datetime
def details():
print("Developed by CO6I_B_15");
print("Your Computer Name is: " + socket.gethostname());
print("Your Computer IP Address is: " + socket.gethostbyname(socket.gethostname()));
print("Time now is: " , datetime.datetime.now());
14.3)
import details
class Degree:
def getDegree(self):
def detail(self):
print("I am an UnderGraduate")
class PostGraduate(Degree):
def detail(self):
print("I am an PostGraduate")
ob1 = Degree()
ob2 = UnderGraduate()
ob3 = PostGraduate()
ob1.getDegree()
ob2.detail()
ob3.detail()
details.details()
Output:
Python Exp 15
15.1)
15.2)
import socket
import datetime
class Drive:
def drive():
class Fly:
def fly():
class Both(Drive,Fly):
ob = Both
ob.drive()
ob.fly()
import details
details.details()
Output:-
Details.py:-
import socket
import datetime
def details():
print("Developed by CO6I_B_15");
print("Your Computer Name is: " + socket.gethostname());
print("Your Computer IP Address is: " + socket.gethostbyname(socket.gethostname()));
print("Time now is: " , datetime.datetime.now());
Python Exp 16
16.1)
16.2)