Results for Python Solved Slips

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

December 31, 2021

    Write a Python program

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 :

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

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

December 31, 2021

    Write a Python program

Slip 29 A) Write a Python GUI program to calculate volume of Sphere by accepting radius as input.

Answer :

pi = 3.1415926535897931

r= 6.0

V= 4.0/3.0*pi* r**3

print('The volume of the sphere is: ',V)

Output :

 

Slip 29 B) Write a Python script to sort (ascending and descending) a dictionary by key and value.

Answer :

names = {1:'Sun' ,2:'Mon' ,4:'Wed' ,3:'Tue' ,6:'Fri' ,5:'Thur' }

#print a sorted list of the keys

print(sorted(names.keys()))

#print the sorted list with items.

print(sorted(names.items()))

Output :

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

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

December 31, 2021

    Write a Python program

Slip 28 A) Write a Python GUI program to create a list of Computer Science Courses using Tkinter module (use Listbox).

Answer :


import tkinter as tk parent = tk.Tk()

parent.geometry("250x200")

label1 = tk.Label(parent,text = "A list of Computer Science Courses ") listbox = tk.Listbox(parent)

listbox.insert(1,"PHP") listbox.insert(2, "Python") listbox.insert(3, "Java") listbox.insert(4, "C#") label1.pack() listbox.pack() parent.mainloop()

Output :

 

Slip 28 B) Write a Python program to accept two lists and merge the two lists into list of tuple.

Answer :

lst1=[1,2,3,5]

lst2=["SVPM","Baramati"]

t1=tuple(lst1)

t2=tuple(lst2)

t3=t1 + t2

print(t3)

Output :

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

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

December 31, 2021

    Write a Python program

Slip 27 A) Write a Python program to unzip a list of tuples into individual lists.

Answer :

l = [(1,2), (3,4), (8,9)]

print(list(zip(*l)))

Output :

 

Slip 27 B) Write Python GUI program to accept a decimal number and convert and display it to binary, octal and hexadecimal number.

Answer :

dec = 344

print("The decimal value of", dec, "is:") print(bin(dec), "in binary.") print(oct(dec), "in octal.") print(hex(dec), "in hexadecimal.")

Output :

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

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

December 31, 2021

   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

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

December 31, 2021

    Write a Python program

Slip 26 A) Write an anonymous function to find area of square and rectangle

Answer :

areaSquare=lambda length : length * length

areaRect=lambda length,width : length * width

l=int(input("Enter Length Value to calcualte area of Square: "))

print("Area of Square:",areaSquare(l))

l=int(input("\n Enter Length Value to calcualte area of Rectangle:"))

w=int(input("Enter Width Value to calcualte area of Rectangle: "))

print("Area of Rectangle:",areaRect(l,w))

Output :

 

Slip 26 B) Write Python GUI program which accepts a sentence from the user and alters it when a button is pressed. Every space should be replaced by *, case of all alphabets should be reversed, digits are replaced by?.

Answer :

Output :

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

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

December 31, 2021

    Write a Python program

Slip 23 A) Write a Python GUI program to create a label and change the label font style (font name, bold, size) using tkinter module.

Answer :


import tkinter as tk parent = tk.Tk()

parent.title("Welcome to India")

my_label = tk.Label(parent, text="Hello", font=("Arial Bold", 90)) my_label.grid(column=0, row=0)

parent.mainloop()


Output :

 

Slip 23 B) Create a class circles having members radius. Use operator overloading to add the radius of two circle objects. Also display the area of circle.

Answer :

Output :


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

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

December 31, 2021

    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

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

December 31, 2021

    Write a Python program

Slip 22 A) Write a python class to accept a string and number n from user and display n repetition of strings by overloading * operator.

Answer :

Output :

 

Slip 22 B) Write a python script to implement bubble sort using list

Answer :

lst=[12,10,17,9,1]

cnt=len(lst)

for i in range(0,cnt-1):

    for j in range(0,cnt-1):

        if lst[j]>lst[j+1]:

            temp=lst[j]

            lst[j]=lst[j+1]

            lst[j+1]=temp

print(lst)

Output :

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

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

December 31, 2021

    Write a Python program

Slip 21 A) Define a class named Rectangle which can be constructed by a length and width. The Rectangle class has a method which can compute the area and Perimeter.

Answer :


class Rectangle:

def     init (self, l, w): self.length = l self.width = w

def rectangle_area(self):

return self.length*self.width newRectangle = Rectangle(12, 10) print(newRectangle.rectangle_area())


Output :

 

Slip 21 B) Write a Python program to convert a tuple of string values to a tuple of integer values.

Original tuple values: (('333', '33'), ('1416', '55'))

New tuple values: ((333, 33), (1416, 55))

Answer :

def Convert_Fun(tuple_str):

    result = tuple((int(x[0]), int(x[1])) for x in tuple_str)

    return result

tuple_str = (('333', '33'), ('1416', '55'))

print("Original tuple values:")

print(tuple_str)

print("\nNew tuple values:")

print(Convert_Fun(tuple_str))

Output :

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