Class Test
Subject: T & T Lab
Each Question carries 3 marks. Answer any 10 Questions.
Full Marks: 30, Time: 1 hr 30
minutes,
Q1. How are lists different from strings when both are sequences?
Q2. How are tuples different from lists when both are sequences?
Q3. Write a program that takes a string with multiple words and then
capitalizes the first letter of each word and forms a new string out
of it.
Q4. Write a program to print alternate characters in a String where
string is entered by the user.
Q5. Write a python function secondLargest(T) which takes as input a tuple T
and returns the second largest element in the tuple.
(May use inbuilt functions too)
Q6. Write a function getPowers(x) that returns a tuple containing x,x 2,x3,and x4.
Read five integers from the user and for each integer read,
print that value raised to the powers 2,3 and 4.
Q7. WAP to accept values from a user. Add a tuple to it and
display its elements one by one. Also display its maximum &
minimum value.
Q8. WAP to input any values for 2 tuples.
Print it, interchange it and then compare them.
Q9. Write a function rowsum() that accepts a 2D list as parameter and
prints the sum of each row.
Eg: 1 2 3
456
789
The output should be:
6
15
24
Q10. Find and write the output of the following python code:
a=10
def call():
global a
a=15
b=20
print(a)
call()
Q11. Find error in following code:-
def DEFA_ARG(n1=1, n2=2,n3):
n1=n1+n2
n2+=n3
print (nl ,n2,n3)
Check()
Check(2, 1)
Check(3,4,5)
Q12.
Create a 5X2 integer array using Numpy from a range between 100 to 200 such that t
difference between each element is 10