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

   Write a Python program

Slip 25 A) Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected

Output : No. of Upper case characters : 3

No. of Lower case Characters : 12

Answer :

def Chk():

    s="The quick Brow Fox"

    cnt=len(s)

    ucnt=0

    lcnt=0

    for i in range(0,cnt):

        if s[i].isalpha()==True:

            if s[i].isupper()==True:

                ucnt=ucnt+1

            elif s[i].islower()==True:

                lcnt=lcnt+1

                

    print("No. of Upper case characters :", ucnt)

    print("No. of Lower case characters :", lcnt)


#main body

Chk()


Output :

 

Slip 25 B) Write a Python script to Create a Class which Performs Basic Calculator Operations.

Answer :

class MathOp:

                def AddOp(self):

                                self.a=int(input("Enter first no:"))

                                self.b=int(input("Enter Second no:"))

                                self.c= self.a + self.b

                                print("Addition is:",self.c)

 

                def SubOp(self):

                                self.a=int(input("Enter first no:"))

                                self.b=int(input("Enter Second no:"))

                                self.c= self.a - self.b

                                print("Sub is:",self.c)


                def MulOp(self):

                                self.a=int(input("Enter first no:"))

                                self.b=int(input("Enter Second no:"))

                                self.c= self.a * self.b

                                print("Addition is:",self.c)

                                print("Multiplication is:",self.c)

#main body


obj=MathOp()


while True:

                print("\n1. Addtion")

                print("2. Substraction")

                print("3. Multiplication")

                print("4. Exit")

 

                ch=int(input("Enter choice to perform any opertaion"))

                if ch==1:

                                obj.AddOp()

                elif ch==2:

                                obj.SubOp()

                elif ch==3:

                                obj.MulOp()

                elif ch==4:

                                print("\nProgram Stop")

                                break

                else:

                                print("Wrong Choice")

Output :

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

1 comment:

surbhi said...

I read your article it is very informative and attractive I hope you will share some more content. python course

Powered by Blogger.