Prasnya
Continue with Google
Loading
IITM BS Week 2 Programming in Python Questions | Prasnya
Programming in Python > Week 2
All PYQs
Topic Wise PYQs
Start Weekly Test
Type:
All
Difficulty:
All
Year:
All
16Q
01
Given the following code snippet, what will be the output? ``` if None: print("None is True") elif 0: print("0 is True") elif "": print("Empty string is True") else: print("All False") ```
Single correct
EASY
3 marks
31 August 2025
02
A system categorizes students based on their marks as follows: Marks Range Category Table (Rendered in LaTeX):
0
≤
Marks
<
40
⟹
0 \le \text{Marks} < 40 \implies
0
≤
Marks
<
40
⟹
Fail
40
≤
Marks
<
60
⟹
40 \le \text{Marks} < 60 \implies
40
≤
Marks
<
60
⟹
Pass
60
≤
Marks
<
80
⟹
60 \le \text{Marks} < 80 \implies
60
≤
Marks
<
80
⟹
Good
80
≤
Marks
≤
100
⟹
80 \le \text{Marks} \le 100 \implies
80
≤
Marks
≤
100
⟹
Excellent Which of the following snippets correctly computes and prints the category after accepting the marks as input? Assume that the input entered by the user will be an integer and will lie only in the range
[
0
,
100
]
[0, 100]
[
0
,
100
]
. Snippet-1: marks = int(input()) ``` A system categorizes students based on their marks as follows: Marks Range Category Table (Rendered in LaTeX):
0
≤
Marks
<
40
⟹
0 \le \text{Marks} < 40 \implies
0
≤
Marks
<
40
⟹
Fail
40
≤
Marks
<
60
⟹
40 \le \text{Marks} < 60 \implies
40
≤
Marks
<
60
⟹
Pass
60
≤
Marks
<
80
⟹
60 \le \text{Marks} < 80 \implies
60
≤
Marks
<
80
⟹
Good
80
≤
Marks
≤
100
⟹
80 \le \text{Marks} \le 100 \implies
80
≤
Marks
≤
100
⟹
Excellent Which of the following snippets correctly computes and prints the category after accepting the marks as input? Assume that the input entered by the user will be an integer and will lie only in the range
[
0
,
100
]
[0, 100]
[
0
,
100
]
. Snippet-1: marks = int(input()) if marks < 40: category = 'Fail' elif marks < 60: category = 'Pass' elif marks < 80: category = 'Good' else: category = 'Excellent' print(category) Snippet-2: marks = int(input()) if marks <= 40: category = 'Fail' elif marks <= 60: category = 'Pass' elif marks <= 80: category = 'Good' else: category = 'Excellent' print(category) ```
Single correct
MEDIUM
3 marks
13 April 2025
03
Consider the following code snippet: Which of the following statements is/are correct? ``` temperature = int(input()) alert = False if temperature > 35: alert = True if temperature > 45: status = '''Extreme Heat''' else: status = '''High Temperature''' elif temperature >= 20: if temperature > 25 and alert: status = '''Moderate''' else: status = '''Pleasant''' print(status) ```
Multiple correct
MEDIUM
3 marks
13 April 2025
04
Given snippet of code below, depending on the value of {placeholder} what will be the output if the input temp is 92? ``` temp = int(input()) if temp > 100: state = 'Hot' else: state = 'Very Warm' {placeholder} temp > 60: if temp > 70: state = 'Warm' else: state = 'Cool' print(state) ```
Single correct
MEDIUM
3 marks
22 December 2024
05
A system categorizes people based on their age as follows:
Marks
Grade
0
≤
Age
<
13
Child
13
≤
Age
<
20
Teenager
20
≤
Age
<
60
Adult
Age
≥
60
SeniorCitizen
\begin{array}{|c|c|} \hline \textbf{Marks} & \textbf{Grade} \\ \hline 0 \le \text{Age} < 13 & \text{Child} \\ \hline 13 \le \text{Age} < 20 & \text{Teenager} \\ \hline 20 \le \text{Age} < 60 & \text{Adult} \\ \hline \text{Age} \ge 60 & \text{SeniorCitizen} \\ \hline \end{array}
Marks
0
≤
Age
<
13
13
≤
Age
<
20
20
≤
Age
<
60
Age
≥
60
Grade
Child
Teenager
Adult
SeniorCitizen
Which of the following snippets computes and prints the category after accepting the age as input? Assume that the input entered by the user will be an integer and will lie only in the range
[
0
,
70
]
[0, 70]
[
0
,
70
]
. Snippet-1 age = int(input()) ``` age = int(input()) if age < 13: category = 'Child' elif age < 20: category = 'Teenager' elif age < 60: category = 'Adult' else: category = 'Senior Citizen' print(category) ``` Snippet-2 age = int(input()) ``` age = int(input()) if age < 13: category = 'Child' if age < 20: category = 'Teenager' if age < 60: category = 'Adult' else: category = 'Senior Citizen' print(category) ```
Single correct
MEDIUM
3 marks
01 September 2024
06
Consider the following code-blocks. `E` is a Boolean expression. Two blocks of code are said to be equivalent if they produce the same output for a given input. Block-1: ``` Consider the following code-blocks. `E` is a Boolean expression. Two blocks of code are said to be equivalent if they produce the same output for a given input. Block-1: if E: print('good') else: print('bad') Block-2: if E: print('good') print('bad') Block-3: print('good') print('bad') Select all true statements. ```
Multiple correct
MEDIUM
3 marks
24 December 2023
07
Consider the following snippet of code. x is a real number. When minmax(x, x) is called, which return statement in the function is executed? ``` def minmax(a, b): if a <= b: return a, b return b, a ```
Single correct
EASY
3 marks
03 September 2023
08
``` print(not(A and B), not(A) and B) ```
Comprehension
EASY
1 marks
03 September 2023
09
``` print(A or B and A or not(B)) ```
Comprehension
EASY
1 marks
03 September 2023
10
``` print(not(A or B), not(A) or B) ```
Comprehension
EASY
1 marks
03 September 2023
11
``` print(not A and B or A and B) ```
Comprehension
EASY
1 marks
03 September 2023
12
Select the correct code block(s) that perform the following task: 1. Accept two strings as input 2. Print Ascending if the first string comes before the second in alphabetical order 3. descending otherwise For example, if the input is as follows: java python then the expected output is Ascending because python comes after java. Assume that all the strings consist of only one word and will be entered in lowercase during the time of input.
Multiple correct
EASY
3 marks
30 April 2023
13
What is the output of the following snippet of code? ``` print(not (A and B), not(A) and B) ```
Comprehension
EASY
1 marks
30 April 2023
14
What is the output of the following snippet of code? ``` print(A or B and A or not(B)) ```
Comprehension
MEDIUM
1 marks
30 April 2023
15
What is the output of the following snippet of code? ``` print(not(A or B), not(A) or B) ```
Comprehension
EASY
1 marks
30 April 2023
16
What is the output of the following snippet of code? ``` print(not A and B or A and B) ```
Comprehension
EASY
1 marks
30 April 2023
Showing 16 questions.
Complete question index for this section:
Question 1 (single):
Question 2 (single):
Question 3 (multiple):
Question 4 (single):
Question 5 (single):
Question 6 (multiple):
Question 7 (single):
Question 8 (comprehension):
Question 9 (comprehension):
Question 10 (comprehension):
Question 11 (comprehension):
Question 12 (multiple):
Question 13 (comprehension):
Question 14 (comprehension):
Question 15 (comprehension):
Question 16 (comprehension):