MauryaHub PYQ Practice

Programming in Python · Quiz 1 · Sep 2025

Programming in Python · Quiz 1 · Sep 2025

← Course papers · Start practice / exam

This page contains the reliably extracted subset, not the complete original paper.

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

0 / 15 published solutions

Question 2 MCQ · 0.0 marks

**Useful Information** **NAT → integer** For all NAT questions in this exam, the answer will always be an integer and not a float value. If the answer to a question is 18, then just enter that value. Do not enter 18.0
6406535107702.
Instructions has been mentioned above.
6406535107703.
This Instructions is just for a reference & not for an evaluation.

A published solution is not available for this question yet.

Report a correction for Q2

Question 3 MCQ · 3.0 marks

Consider the following Python code. What will be the output? s = "programming" print(s[::-1].replace("g", "#"))
6406535107704.
#nimmarrop#
6406535107705.
#nimmar#orp
6406535107706.
programmin#
6406535107707.
gni#marropg

A published solution is not available for this question yet.

Report a correction for Q3

Question 4 MCQ · 3.0 marks

Consider the following Python code. What will be the output? x, y, z = "", "python", 0 print((x or y) and (z or len(y)))
6406535107708.
6
6406535107709.
""
6406535107710.
"python"
6406535107711.
0
6406535107712.
True

A published solution is not available for this question yet.

Report a correction for Q4

Question 5 MCQ · 3.0 marks

Consider the following python code. What will the value stored in x at the end of the program execution? x = 5 x = x + 2.0 x = str(x) + "3" x = x * 2 x = [x] x = x + [10]
6406535107713.
['7.03', '7.03', 10]
6406535107714.
['7.03', 10]
6406535107715.
['7.037.03']
6406535107716.
['7.037.03', 10]

A published solution is not available for this question yet.

Report a correction for Q5

Question 6 MCQ · 4.0 marks

You have a list of lists: You want to **compute the sum of all even numbers greater than 3**. Consider the two code snippets below (with the condition left blank): **Snippet-1** s = 0 for row in data: for val in row: __________: s += val print(s) **Snippet-2** s = 0 i = 0 while i < len(data): j = 0 while _________: if data[i][j] % 2 == 0 and data[i][j] > 3: s += data[i][j] j += 1 i += 1 print(s) Which of the following conditions, when filled in the blanks in both snippets, will give the **correct result**?
6406535107717.
**Snippet 1:** if element % 2 == 0 and element > 3: **Snippet 2:** i > len(data[j]
6406535107718.
**Snippet 1:** if element % 2 != 0 and element > 3: **Snippet 2:** i < len(data[j]
6406535107719.
**Snippet 1:** if element % 2 == 0 and element > 3: **Snippet 2:** j < len(data[i]):
6406535107720.
**Snippet 1:** if element % 2 == 0 and element < 3: **Snippet 2:** j > len(data[i]):

A published solution is not available for this question yet.

Report a correction for Q6

Question 7 MCQ · 4.0 marks

Assume s is a str variable. What is the type of the expression "".join(sorted(set(s.lower()))) ?
6406535107721.
int
6406535107722.
set
6406535107723.
list
6406535107724.
bool
6406535107725.
str
6406535107726.
NoneType
6406535107727.
The code raises an error.

A published solution is not available for this question yet.

Report a correction for Q7

Question 8 MSQ · 4.0 marks

Consider the following Python code: t = (5, [10, 20], (30, [40, 50],(30,))) Which of the following statements are **valid**? (Select all that apply)
6406535107728.
t[1].append(25)
6406535107729.
t[2] += (60,)
6406535107730.
t[2][0] = 35
6406535107731.
t[2][2].append(60)
6406535107732.
t[2][1][0] = 45

A published solution is not available for this question yet.

Report a correction for Q8

Question 9 MSQ · 3.0 marks

Consider the below code. if x: print('x') else: if y: if z: print('z') print('y') else: print('none') Select the possible output(s) of the given code, assuming any possible values for x , y , and z .
6406535107733.
x
6406535107734.
z y
6406535107735.
x y
6406535107736.
none
6406535107737.
x z
6406535107738.
y

A published solution is not available for this question yet.

Report a correction for Q9

Question 10 NAT · 4.0 marks

Consider the following Python code: for i in range(1, 6): for j in range(1, 6): for k in range(1, 2): if i == j: print("-") else: print("*", end=" ") print("+") How many lines will be printed when this code is executed?

A published solution is not available for this question yet.

Report a correction for Q10

Question 11 NAT · 3.0 marks

Consider the following Python code: for i in range(1, 5): for j in range(1, 5): if j == 3: break if i == 2: continue print(i, j) How many lines will be printed when this code is executed?

A published solution is not available for this question yet.

Report a correction for Q11

Question 12 NAT · 3.0 marks

Consider the following Python code: P = {1, 2, 3, 4} Q = {3, 4, 5, 6} R = {4, 5, 6, 7} S = {2, 4, 6, 8} result = ((P | Q) - R) & S print(result) How many elements will be present in result?

A published solution is not available for this question yet.

Report a correction for Q12

Question 13 MCQ · 4.0 marks

Consider the following snippet of code and answer the given sub-questions: def analyze(data): result = [] for item in data: if isinstance(item, tuple): total = 0 for x in item: if x % 2 == 0: total += x result.append(total) elif isinstance(item, int) and item % 2 == 1: result.append(item * 3) else: continue return result sample = [(2, 5, 6), 7, (1, 3), 4, (8, 2, 1)] output = analyze(sample)
What is the value of output after executing the given code?
6406535107742.
[8, 21, 0, 4, 10]
6406535107743.
[8, 21, 4, 2, 10]
6406535107744.
[8, 21, 0, 10]
6406535107745.
[8, 7, 0, 10]

A published solution is not available for this question yet.

Report a correction for Q13

Question 14 NAT · 4.0 marks

Consider the following snippet of code and answer the given sub-questions: def analyze(data): result = [] for item in data: if isinstance(item, tuple): total = 0 for x in item: if x % 2 == 0: total += x result.append(total) elif isinstance(item, int) and item % 2 == 1: result.append(item * 3) else: continue return result sample = [(2, 5, 6), 7, (1, 3), 4, (8, 2, 1)] output = analyze(sample)
How many times is the inner for x in item: loop executed in total when running analyze(sample) ?

A published solution is not available for this question yet.

Report a correction for Q14

Question 15 MCQ · 4.0 marks

Consider the following code: def flipper(matrix): transformed = [] for row in matrix: new_row = [] for element in row: if element < 0: new_row.append(0) elif element % 2 == 0: new_row.append(element * 2) else: new_row.append(element * 3) transformed.append(new_row) result = [ val for sub in transformed for val in sub if val > 5 ] return transformed, result matrix = [[1, -2, 3], [4, 5, -6], [7, 8]] out1, out2 = flipper(matrix) print(out1) print(out2) Answer the subquestions based on the given data.
What is the value of out1 after executing the code?
6406535107747.
[[1, -4, 9], [8, 15, -12], [21, 16]]
6406535107748.
[[3, 0, 9], [8, 15, 0], [21, 16]]
6406535107749.
[[3, 0, 9], [4, 15, 0], [21, 16]]
6406535107750.
[[1, 0, 3], [8, 15, 0], [21, 16]]

A published solution is not available for this question yet.

Report a correction for Q15

Question 16 MCQ · 4.0 marks

Consider the following code: def flipper(matrix): transformed = [] for row in matrix: new_row = [] for element in row: if element < 0: new_row.append(0) elif element % 2 == 0: new_row.append(element * 2) else: new_row.append(element * 3) transformed.append(new_row) result = [ val for sub in transformed for val in sub if val > 5 ] return transformed, result matrix = [[1, -2, 3], [4, 5, -6], [7, 8]] out1, out2 = flipper(matrix) print(out1) print(out2) Answer the subquestions based on the given data.
What is the value of out2 after executing the code?
6406535107751.
[3, 9, 8, 15, 21, 16]
6406535107752.
[9, 8, 15, 21, 16]
6406535107753.
[8, 15, 21, 16]
6406535107754.
[3, 0, 9, 8, 15, 0, 21, 16]       **Sem1 CT** **Section Id :** 640653105905 **Section Number :** 2 **Section type :** Online **Mandatory or Optional :** Mandatory **Number of Questions :** 14 **Number of Questions to be attempted :** 14 **Section Marks :** 50 **Display Number Panel :** Yes **Section Negative Marks :** 0 **Group All Questions :** No **Enable Mark as Answered Mark for Review and** No **Clear Response :** **Section Maximum Duration :** 0 **Section Minimum Duration :** 0 **Section Time In :** Minutes **Maximum Instruction Time :** 0

A published solution is not available for this question yet.

Report a correction for Q16