TORONTO KIDS COMPUTER CLUB | Thursday 18:30 Python Practice 22.08.04.
20939
post-template-default,single,single-post,postid-20939,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Thursday 18:30 Python Practice 22.08.04.

08 Aug Thursday 18:30 Python Practice 22.08.04.

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()
No Comments

Sorry, the comment form is closed at this time.