CP QB PT-3 Harish Kumar

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

SETHU INSTITUTE OF TECHNOLOGY

PULLOOR, KARIAPATTI – 626 115


PT3-QUESTION BANK

Branch & Sem. : Common to all Branches except CSBS / I Date of Exam :
Subject Code : 19UCS108 Total Marks : 50
Subject Name : Problem Solving and Python Programming Duration : 1.30 Hrs
Prepared By Approved By : HOD-CSE
Part A

1. Function which is called by itself is


a) Declaration of function b) Function definition
c) Recursion d) None

2. The variable function defined outside a function is referred to as


a) Local variable b) Only Variable
c) Global Variable d) None of the above

3. What is the output of the following program


y=8
z=lambda x: x*y
print (z(6))
a. 48 b.14 c. 64 d. Error

4. Collection of modules is called as


a. Package b. file
c. list d. dictionary

5. What is the output of the following program?


L1 = [1, 2, 3, 4]
L2 = L1
L3 = L1.copy()
L4 = list(L1)
L1[0] = [5]
print(L1, L2, L3, L4)

a)[5,2,3,4][5,2,3,4][1,2,3,4][1,2,3,4]
b)[[5],2,3,4][[5],2,3,4][[5],2,3,4][1,2,3,4]
c)[5,2,3,4][5,2,3,4][5,2,3,4][1,2,3,4]

6. What type of data is: a=[(1,1),(2,4),(3,9)]?


a) Array of tuples b) List of tuples
c) Tuples of lists d) Invalid type

7. Which of the following is immutable object in python?


a. Tuple b. String c. Both a & b d. List

8. Which of the following is mutable object in python?


a. Tuple b. Bool c. Int d. List

9.Append() method in list is used to insert the element at the


a)Start of List b) Middle of the List c) End of the List d) None of the above

10. Which of the following function header is correct?


a) def Demo(P,Q=10): b) def Demo(P=10,Q=20):
c) def Demo(P=10,Q) d) Both a and b
11. Which keyword is used for function?
a. Fun b.Define c).def d) Function

12. Analyze the output for following string slice str1="HELLO" ,then print(str1[:3])
a. prin a. H b. HEL c. HELL d. HE

13. Analyze the output for following string membership str1="HELLO" ,then m in str1
a. False b. True c. Undefined d. conditional values
14. What will be the output of the following program?
Vowels=”AEIOU”
for i in Vowels:
print (i)

a. AEIOU b.AE c. EIOU d. Error

15. What is the output when we execute list(“hello”)?


a=((1,2),*7
Print(len(a[3:6]))

a)2 b)4 c)3 d)error

16. T1 = (1)
T1 += 5
print(T1)

a. Type Error b. (1,5,3,4) c)1 d) 6

PART B

1. A game has to be made from marbles of five colors; yellow, blue, green, red and Violet where
five marbles has to be kept one upon another. Write a python program using recursion, to find
how many ways these marbles can be arranged.

2. Four People A, B, C, D are sitting in a Circular arrangement. Write a python program using
recursion, to find how many ways their seating can be arranged.

3. Develop a solution to identify the right angle triangle while giving the sides of a triangle.
(Recall from the Pythagoras theorem that in a right triangle, the square of one side equals the
sum of the squares of other two sides)

4. Describe function prototype with example

5. Demonstrate with code the various operations that can be performed on list methods ?

6. Define Dictionary? How it created and accesses the different methods in Dictionary with example?

7. In a class of 50 numbers of students, 6 students are selected for state cricket academy.
Sports faculty of this school has to report to the state cricket academy about the selected
students’ physical fitness. Here is one of the physical measures of the selected students’;
Height in cm is given for those 6 selected students [153,162,148,167,175,151]. By
implementing functions, do the following operations.
(i) State academy selector has to check whether the given height is present in
the selected students list or not.
(ii) State academy selector has to order the height of students in an incremental
manner.
(iii) State academy selector has to identify the maximum height from the list.
8. Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The
objective of the puzzle is to move the entire stack to another rod, obeying the following
simple rules:
Here is a high-level outline of how to move a tower from the starting pole, to the goal
pole, using an intermediate pole:
1. Move a tower of height-1 to an intermediate pole, using the final pole.
2. Move the remaining disk to the final pole.
3. Move the tower of height-1 from the intermediate pole to the final pole using original
pole.

9. Demonstrate with code the various operations that can be performed on list methods?

10. Write a Python recursive function which computes the nth Fibonacci number. Fibonacci
numbers are defined as fib(0)=1,fib(1)=1,fib(n)=fib(n-1)+fib(n-2) and then find the 8th
Fibonacci number.

11. A musical album company has ‘n’ number of musical albums. The PRO of this company
wishes to do following operations based on some scenarios:
(i) Name of the album starts with ‘s’ or ‘S’.
(ii) Name of the album which contains ‘jay’ as substring.
(iii) Check whether the album name presents in the repository or not.
(iv) Count number of vowels and consonants in the given album name.

You might also like