Slip 30 A)
Write a Python GUI program to accept a string and a character from user and
count the occurrences of a character in a string.
Answer :
s = "The TYBBACA Student is
clever." print("Original string:")
print(s)
print("Number of occurrence of 'o' in the said string:") print(s.count("o"))
Output :
Slip 30 B)
Python Program to Create a Class in which One Method Accepts a String from the
User and Another method Prints it. Define a class named Country which has a
method called print Nationality. Define subclass named state from Country which
has a mehtod called printState. Write a method to print state, country and
nationality.
Answer :
class Country:
def
AcceptCountry(self):
self.cname=input("Enter
Country Name: ")
def
DisplayCountry(self):
print("Country
Name is:", self.cname)
class State(Country):
def
AcceptState(self):
self.sname=input("Enter
State Name: ")
def
DisplayState(self):
print("State
Name is:", self.sname)
#main body
Obj=State()
Obj.AcceptCountry()
Obj.AcceptState()
Obj.DisplayCountry()
Obj.DisplayState()
Output :
1 comment:
Hello please upload TYBBA(CA) practical slips pdf (questions only) of SPPU
Post a Comment