T.Y.B.B.A.(C.A.) Semester – V (CBCS 2019 Pattern) University Practical Examination Lab Course: (CA-506) Python
Slip 1
A) Write a Python program to accept n numbers in list and remove duplicates from a list. [15 M]
CODE :
n=int(input('Enter number of elements : '))
for i in range(n):
value=int(input())
marks.append(value)
print(marks)
new_marks=[]
for x in marks:
if x not in new_marks:
new_marks.append(x)
print(new_marks)
B) Write a Python GUI program to take accept your birthdate and output your age when a button is pressed. [25 M]
CODE :
Slip 2
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 Brown Fox' Expected Output: No. of Upper case characters: 3 No. of Lower case characters: 13 [15 M]
CODE :
B) Write Python GUI program to create a digital clock with Tkinter to display the time. [25 M]
CODE :
Slip 3
A) Write a Python program to check if a given key already exists in a dictionary. If key exists replace with another key/value pair. [15 M]
CODE :
B) Write a python script to define a class student having members roll no, name, age, gender. Create a subclass called Test with member marks of 3 subjects. Create three objects of the Test class and display all the details of the student with total marks. [25 M]
Code :
Slip 4
A) Write Python GUI program to create background with changing colors [15 M]
CODE :
B) Define a class Employee having members id, name, department, salary. Create a subclass called manager with member bonus. Define methods accept and display in both the classes. Create n objects of the manager class and display the details of the manager having the maximum total salary (salary+bonus). [25 M]
CODE :
Slip 5
A) Write a Python script using class, which has two methods get_String and print_String. get_String accept a string from the user and print_String print the string in upper case. [15 M]
CODE :
B) Write a python script to generate Fibonacci terms using generator function. [25 M]
CODE :
Slip 6
A) Write python script using package to calculate area and volume of cube and sphere [15 M]
CODE:
B) Write a Python GUI program to create a label and change the label font style (font name, bold, size). Specify separate check button for each style. [25 M]
Slip 7
A) Write Python class to perform addition of two complex numbers using binary + operator overloading. [15 M]
CODE :
B) Write python GUI program to generate a random password with upper and lower case letters.
CODE :
Slip 8
A) Write a python script to find the repeated items of a tuple [15 M]
CODE :
B) Write a Python class which has two methods get_String and print_String. get_String accept a string from the user and print_String print the string in upper case. Further modify the program to reverse a string word by word and print it in lower case. [25 M]
CODE :
Slip 9
A) Write a Python script using class to reverse a string word by word [15 M]
CODE :
B) Write Python GUI program to accept a number n and check whether it is Prime, Perfect or Armstrong number or not. Specify three radio buttons. [25 M]
CODE:
Slip 10
A) Write Python GUI program to display an alert message when a button is pressed. [15 M]
CODE :
B) Write a Python class to find validity of a string of parentheses, '(', ')', '{', '}', '[' ']’. These brackets must be close in the correct order. for example "()" and "()[]{}" are valid but "[)", "({[)]" and "{{{" are invalid. [25 M]
class py_solution: def is_valid_parenthese(self, str1): stack, pchar = [], {"(": ")", "{": "}", "[": "]"} for parenthese in str1: if parenthese in pchar: stack.append(parenthese) elif len(stack) == 0 or pchar[stack.pop()] != parenthese: return False return len(stack) == 0 print(py_solution().is_valid_parenthese("(){}[]")) print(py_solution().is_valid_parenthese("()[{)}")) print(py_solution().is_valid_parenthese("()"))
Slip 11
A) Write a Python program to compute element-wise sum of given tuples. Original lists: (1, 2, 3, 4) (3, 5, 2, 1) (2, 2, 3, 1) Element-wise sum of the said tuples: (6, 9, 8, 6) [15 M]
CODE:
Original lists: (1, 2, 3, 4) (3, 5, 2, 1) (2, 2, 3, 1)
Element-wise sum of the said tuples: (6, 9, 8, 6)
B) Write Python GUI program to add menu bar with name of colors as options to change the background color as per selection from menu option. [25 M]
CODE :
Slip 12
A) Write a Python GUI program to create a label and change the label font style (font name, bold, size) using tkinter module. [15 M]
CODE:
B) Write a python program to count repeated characters in a string.
Sample string: 'thequickbrownfoxjumpsoverthelazydog'
Expected output: o-4, e-3, u-2, h-2, r-2, t-2 [25 M]
CODE :
Expected output: o-4, e-3, u-2, h-2, r-2, t-2
0 Comments