Week 7 Programing with python Questions | Prasnya
Prasnya
Continue with Google
Practice path
Dashboard
Exam
Qualifier / Quiz 1
Go to subject
Programing with python
Go to chapter
Week 7
All questions
Give Mock Test
Topic wise questions
Filters
Question type / Difficulty / Years (14)
Question type
14
Difficulty
14
Years
14
Q1
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. Which conditions, when filled in the blanks in both snippets, will give the correct result? 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) ```
Single correct
OCTOBER 26, 2025
OCTOBER 26, 2025
Q2
What is the value of `out1` after executing the code?
Comprehension
OCTOBER 26, 2025
OCTOBER 26, 2025
Q3
What is the value of `out2` after executing the code?
Comprehension
OCTOBER 26, 2025
OCTOBER 26, 2025
Q4
What is the value of `output` after executing the given code snippet?
Comprehension
JULY 13, 2025
JULY 13, 2025
Q5
In the given code, if we change the condition to `if element % 2 == 0` at line 7, then what is the value of `output` after executing it?
Comprehension
JULY 13, 2025
JULY 13, 2025
Q6
What is the first line of the output?
Comprehension
JULY 07, 2024
JULY 07, 2024
Q7
What is the second line of the output?
Comprehension
JULY 07, 2024
JULY 07, 2024
Q8
What is the output of the following snippet of code? ``` P = [[1, 2], [4, 3]] Q = [[4, 1], [9, 3]] R = [] for i in range(2): row = [] for j in range(2): if P[i][j] - Q[i][j] > 0: row.append(1) elif P[i][j] == Q[i][j]: row.append(0) else: row.append(-1) R.append(row) print(R) ```
Single correct
OCTOBER 29, 2023
OCTOBER 29, 2023
Q9
What is the output of the following snippet of code? ``` p = 1 M = [[1, 3, 4], [2, -1, 3], [-2, 1, 2]] m = len(M) n = len(M[0]) for i in range(m): for j in range(n): p = p * M[i][j] print(p) ```
Integer answer
OCTOBER 29, 2023
OCTOBER 29, 2023
Q10
Select all matrices, represented as lists of lists `M`, for which the above snippet of code prints `True` to the console. ``` # Look at the options for the value of M n = len(M) flag = True for i in range(n): for j in range(n): if (i != j) and (M[i][j] != 0): flag = False break elif (i == j) and (M[i][j] != 1): flag = False break if flag == False: break print(flag) ```
Multiple correct
JULY 16, 2023
JULY 16, 2023
Q11
Select all matrices `M` for which the following code prints `True` to the console. ``` n = len(M) flag = True for i in range(n): for j in range(n): if (i != j) and (M[i][j] + M[j][i] != 0): flag = False print(flag) ```
Multiple correct
OCTOBER 16, 2022
OCTOBER 16, 2022
Q12
NOTE: Enter your answer to the nearest integer. `R` is a zero-matrix, all entries are zeros, of size
3
×
3
3 \times 3
. Let ``` P = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Q = [[1, 1, -1], [1, 1, -1], [1, 1, -1]] R = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] ``` What is the output of the following snippet of code? ``` val = 0 for i in range(3): for j in range(3): R[i][j] = P[i][j] * Q[i][j] val = val + R[i][j] print(val) ```
Integer answer
OCTOBER 16, 2022
OCTOBER 16, 2022
Q13
Select all matrices `M` for which the following code prints `True` to the console. ``` # Look at the options for the value of M n = len(M) flag = True for i in range(n): for j in range(n): if (i != j) and (M[i][j] != M[j][i]): flag = False print(flag) ```
Multiple correct
JUNE 05, 2022
JUNE 05, 2022
Q14
`M` is a matrix, represented as a list of lists, that has already been defined. The dimension of `M` is
m
i
m
e
s
n
m imes n
. Assume that both
m
m
and
n
n
are greater than or equal to
2
2
and all elements of `M` are integers. Select all correct options about the code given below. ``` # M is a matrix (list of lists) that has already been defined n = len(M[0]) flag = True for i in range(n): if M[0][i] - M[-1][i] != 1: flag = False print(flag) ```
Multiple correct
JUNE 05, 2022
JUNE 05, 2022
Showing 14 questions.