






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A practice quiz on conditional statements in python, designed to test understanding of basic programming logic. It includes multiple-choice questions covering if-else structures, logical operators, and their application in determining outputs and evaluating conditions. The quiz assesses the ability to write code snippets for tasks such as checking even/odd numbers, calculating grades based on average marks, and identifying types of triangles based on side lengths. It serves as a practical assessment tool for students learning python programming, focusing on the correct syntax and application of conditional statements to solve simple problems. The quiz also covers error identification and debugging in python code, enhancing problem-solving skills. It is suitable for beginners and intermediate learners looking to reinforce their understanding of conditional logic in python.
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Course Content
Type : Practice Quiz
Attempts : 1/
Questions : 10
Time : 1h
Your Marks : 10/
Instructions
Attempt #
Nov 29, 2022, 3:36 PM
Marks: 10
Q No: 1 Correct Answer
What will be the output of the following code?
a = 56
if a == 10:
print("Hello")
else:
print("Good Bye")
Marks: 1/
"Good Bye"
Good Bye
You Selected
Anything inside the print statement is printed as an output. The body of the print function is
defined with the help of double quotation marks or single quotation marks.
So, print('a') or print("a") returns a as the output.
Q No: 2
Choose the appropriate snippet to check whether a number is even or odd:
Marks: 1/
Hello
Correct Answer
Perimeter of the rectangle is less than the Area of the rectangle
Perimeter of the rectangle is greater than the Area of the rectangle
Area of the rectangle is greater than the Perimeter of the rectangle
You Selected
Area of the rectangle is less than the Perimeter of the rectangle
Q No: 4
Marks: 1/
Which among the following code snippets can be used to calculate the average marks of a
student in 5 subjects, and give grades according to the following rules:
If average > 90, then Grade = A
If average > 80, then Grade = B
If average > 70, then Grade = C
If average > 60, then Grade = D
If average > 50, then Grade = E
length = 5
breadth = 10
Area = length * breadth
Perimeter = 2 * (length + breadth)
if Area > Perimeter:
print("Area of the rectangle is greater than the Perimeter of the rec
else:
print("Perimeter of the rectangle is greater than the Area of the rec
Correct Answer
You Selected
avg = (m1 + m2 + m3 + m4 + m5) / 5
print("Average=", avg)
if avg > 90:
print("Grade A")
elif avg > 80:
print("Grade B")
elif avg > 70:
print("Grade C")
elif avg > 60:
print("Grade D")
elif avg > 50:
m1 = 72
m2 = 85
m3 = 96
m4 = 42
m5 = 95
m1 = 72
m2 = 85
m3 = 96
m4 = 42
m5 = 95
avg = (m1 + m2 + m3 + m4 + m5) / 4
print("Average =", avg)
if avg > 90:
print("Grade A")
elif avg > 80:
print("Grade B")
elif avg > 70:
print("Grade C")
elif avg > 60:
print("Grade D")
elif avg > 50:
print("Grade E")
else:
print("Fail")
missing code 1 - print("isosceles triangle")
missing code 2 - print("Equilateral triangle")
missing code 3 - print("Scalene triangle")
missing code 1 - print("Scalene triangle")
missing code 2 - print("Equilateral triangle")
missing code 3 - print("isosceles triangle")
Q No: 6
What will be the output of the following code?
Marks: 1/
print("Grade C")
r r
print("Grade D")
missing code 2 - print("Scalene triangle")
else if avg > 50:
i i
else:
print("Fail")
missing code 1 - print("Equilateral triangle")
You Selected
missing code 2 - print("isosceles triangle")
missing code 3 - print("Scalene triangle")
a = "I am a Data Scientist"
if "Data" in a:
print("It is present")
else:
print(False)
Correct Answer
It is present
You Selected
SyntaxError: EOL while scanning string literal
Number is Positive
Number is negative
SyntaxError: invalid syntax
SyntaxError: EOL while scanning string literal
You Selected
Q No: 7
What will be the output of the following Python code?
Marks: 1/
Q No: 8
Suppose x = 20 and y = 30. Choose the appropriate snippet to check if x is less than y:
Marks: 1/
True
False
a = - 99
if a > 0:
print("Number is Positive)
else:
print("Number is negative")
Correct Answer
Correct Answer
Group 1: Age < 18, Minors who are not eligible to work
Group 2: 18 <= Age <= 60, Eligible to work
Group 3: Age > 60, Too old to work as per govt. regulations
age = int(input('Enter your age: '))
if age < 18:
print("Not Eligible for work")
elif age > 18 and age < 60:
print("Eligible to work")
else:
print("Too old to work as per the government rules")
You Selected
age = int(input('Enter your age: '))
if age < 18:
print("Not Eligible for work")
elif age >= 18 and age <= 60:
print("Eligible to work")
else:
print("Too old to work as per the government rules")
age = int(input('Enter your age: '))
if age < 18:
print("Not Eligible for work")
else if age > 18 and age < 60:
print("Eligible to work")
else:
print("Too old to work as per the government rules")
age = int(input('Enter your age: '))
if age < 18:
print("Not Eligible for work")
else if age >= 18 and age <= 60:
print("Eligible to work")
Previous Next
else:
print("Too old to work as per the government rules")