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

    Write a Python program

Slip 24 A) Write a Python Program to Check if given number is prime or not. Also find factorial of the given no using user defined function.

Answer :

 

def Prime(num):

                flag=0

                for i in range(2,num):

                                if num%i==0 :

                                                flag=1

                                                break

                                if flag==0:

                                                print("Number is Prime")

                                else:

                                                print("Number is Not Prime")

                def Fact(num):

                                f=1

                                for i in range(1,num+1):

                                                f=f*i

                                print("Factorial of Given number is:",f)

#main body

n=int(input("Enter any number to Check:"))

Prime(n)

Fact(n)

 

Output :

 

Slip 24 B) Write Python GUI program which accepts a number n to displays each digit of number in words.

Answer :

                def printValue(digit):

            if digit == '0':

print("Zero ", end = " ")

elif digit == '1':

    print("One ", end = " ")

elif  digit == '2':

    print("Two ", end = " ")

elif digit=='3':

    print("Three",end=" ")

            elif digit == '4':

    print("Four ", end = " ")

elif digit == '5':

    print("Five ", end = " ")

elif digit == '6':

    print("Six ", end = " ")

elif digit == '7':

    print("Seven", end = " ")

elif digit == '8':

    print("Eight", end = " ") 

elif digit == '9':

    print("Nine ", end = " ")


def printWord(N):

i = 0

length = len(N) while i < length:

printValue(N[i])

i += 1

N = "123"

printWord(N)

Output :

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

No comments:

Powered by Blogger.