Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 17 Answers

   Write a Python program

Slip 17 A) Write Python GUI program that takes input string and change letter to upper case when a button is pressed.

Answer :

Output :

 

Slip 17 B) Define a class Date (Day, Month, Year) with functions to accept and display it. Accept date from user. Throw user defined exception “invalid Date Exception” if the date is invalid.

Answer :

class MyDate:

                def accept(self):

                                self.d=int(input("Enter Day:"))

                                self.m=int(input("Enter Month:"))

                                self.y=int(input("Enter Year:"))

                def display(self):

                                try:

                                        if self.d>31:

                                                  raise ValueError("Day value is greater than 31")

                                         if self.m>12:

                                                   raise ValueError("Month Value is Greater than 12")

                                                    print("Date is: ", self.d, "-" ,self.m , "-",self.y )

                                except ValueError as e:

                                print(e)

#main body

Obj= MyDate()

Obj.accept()

Obj.display()

Output :

Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 17 Answers Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Python Practical Slip 17 Answers Reviewed by technical_saurabh on December 31, 2021 Rating: 5

No comments:

Powered by Blogger.