Class XII UT 1 CS Set A
Class XII UT 1 CS Set A
Section A
1. State True or False: “In a Python program, if a break statement is given in a nested
loop, it terminates the execution of all loops in one go.”
2. What will be the output of the following statement:
print(3-2**2**3+99/11)
3. Select the correct output of the code:
4. Which of the following will delete key-value pair for key = “Red” from a dictionary D1?
5. Consider the statements given below and then choose the correct output from the
given options:
pride="#G20 Presidency"
print(pride[-2:2:-2])
6. What possible outputs(s) will be obtained when the following code is executed?
Section B
13. Rao has written a code to input a number and check whether it is prime or not.
His code is having errors. Rewrite the correct code and underline the corrections
Made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n’)
14. Predict the output of the Python code given below:
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
15.Write a python program to remove duplicates from a given list:-
a=[10,20,30,20,10,50,60,40,80,50,40]
16. Write a program to calculate the length of a string:”python program”
Section C
17. Write a function listcharge(Arr) in python, which accepts a list of numbers and
replace each even number by value 10 and multiply odd number by 5.
Where a=[10,20,23,45]
listchange(a)
Output:- [10,10,115,225]
18. Write a function str_reverse() to reverse a string
Sample string: “python123”
Expected output:- “321nohtyp”