08 Dec Aurora Saturday 13:00 Python Practice 12.05.
Question 1:
Create a Student class and make the following methods to :
- __init__() – Initialize it with name and roll number.
- __str__() – Display all information of the student.
- setAge() – It should assign age to student.
- setMarks() – It should assign marks to the student.
Question 2:
Create a Time class:
- Time(hours, minutes) will create an Time object and initialize it with hours and minutes.
- Make a method addTime(hours, minutes) which should add by arguments hours and/or minutes
- Make a method displayTime which should print the time.
- Make a method DisplayMinute which should display the total minutes in the Time. E.g.- (1 hr 2 min) should display 62 minute.
Sample Program:
Class Time:
def __init__(self, hours, minutes):
# write your program here
def addTime(self, hours, minutes):
# write your program here
def displayTime(self):
# write your program here
def displayMinute(self):
# write your program here
h = int(input('Hours: '))
m = int(input('Minutes: '))
myTime = Time(h, m)
myTime.displayTime()
myTime.displayMinute()
more_hours = int(input('How many hours do you want to add: '))
more_minutes = int(input('How many minutes do you want to add: '))
myTime.addTime(more_hours, more_minutes)
myTime.displayTime()
myTime.displayMinute()
Sorry, the comment form is closed at this time.