Practice Worksheet Cs
Practice Worksheet Cs
Class – 12th
1-What is the default return value for a function that does not return any value explicitly
a) None
b) Int
c) Double
d) Null
2- Which of the function call can be used to invoke the below function definition
def test(a,b,c,d):
a) test(1,2,3,4)
b) test(a=1,2,3,4)
c) test(a=1,b=2,c=3,4)
d) test(a=1,b=2,c=3,d=4)
a) static variable
b) global variable
c) local variable
d) an automatic variable
def sample(x=5):
return x * 2
print(sample())
1. 5
2. 10
3. Error
4. None
6-Assertion-Reasoning Question
Assertion (A): Python is a dynamically typed language.
Reason (R): In Python, a variable’s data type is explicitly declared before assigning a value.
Options:
7-Write a Python program that creates a dictionary named places where the keys represent city IDs
and the values represent city names. The program should then display only those city names that
contain the letter "o" in them.
result = A * B
A, B = B, A
return A
X = 10
Y=5
X = compute(X, Y)
print(X, "@", Y)
Y = compute(Y)
9-Write a Python program that takes two lists, L and M, of the same size and creates a new list, N,
where each element in N is the absolute difference between the corresponding elements in L and M.
L = [3, 1, 4]
M = [1, 5, 9]
Expected output:
N = [2, 4, 5]
Example Input:
sentence = "come let us have some fun let us enjoy"
Example input
w = "TELEVISION"
n=2
output
TE_EVISI_N
11- Write a function LeftRotate(arr, n) in Python that accepts a list arr of numbers and an integer n.
The function should rotate the list to the left by n positions.
Input
n=2
output