





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
Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Course Content
Type : Practice Quiz
Attempts : 1/
Questions : 9
Time : 1h
Your Marks : 10/
Instructions
Attempt #
Nov 29, 2022, 3:46 PM
Marks: 10
Q No: 1 Correct Answer
Marks: 1/
Which among the below snippets can be used to print all integers between - 10 to - 1 including
both - 10 and - 1?
You Selected
for i in range(-10, 0, 1):
print(i)
for i in range(-10, - 1, - 1):
print(i)
for i in range(-10, 0, - 1):
print(i)
The for loop in Python can be used to iterate over a sequence. A sequence of numbers from
n = 10
i = 1
while i <= n:
print(i)
Q No: 2
Marks: 1/
Which of the following snippets can be used to complete the code to print numbers from 1 to
for i in range(-10, - 1, 1):
print(i)
Correct Answer
Prints the square of the numbers from 1 to 10
Prints the multiplication table of 8
Prints the numbers from 1 to 10
Prints the power table of 8 You Selected
The ** operator in Python raises the number on the left to the power of the exponent of the
right. Hence, the given snippet prints the power table of 8.
Q No: 4
What will be the output of the following Python code?
Marks: 1/
Q No: 5
Marks: 1.50/1.
Choose the appropriate snippet to print the messages with the following information.
For numbers 1 to 100:
If a number is divisible by 3, then print Fizz.
If a number is divisible by 5, then print Buzz.
If a number is divisible by 3 and 5 both, then print FizzBuzz.
if condition:
statement(s)
n = 8
for i in range(1, 11):
print("{} ^ {} =".format(n, i), n**i)
Correct Answer
Correct Answer
If a number is neither divisible by 3 or 5, just print the number.
sum = 0
for i in range(1, 101):
print(sum)
sum = sum + i You Selected
i = i + sum
sum = sum * i
In each iteration, the current number(i) is added to the sum variable to find the sum of all the
numbers.
Q No: 7
Marks: 1.50/1.
Choose the appropriate snippet to find all such numbers which are divisible by 7 but are not a
multiple of 5, between 202 and 320 (both included):
e
a n q
d u n
i % o
nu
b
o 1 to 100. The correct condition to print
'FizzBuzz' is
elif (i % 3 == 0):
print("Fizz")
Q No: 6
elif(i % 5 == 0):
print("Buzz")
else:
Correct Answer
Marks: 1/
Which of the can be used to complete the code to find the sum of all numbers
from 1 to 100:
Correct Answer
You Selected
for i in range(202, 321):
if i % 7 == 0 and i % 5 != 0:
print(i)
for i in range(202, 320):
if i % 7 == 0 and i % 5 == 0:
print(i)
range(202, 321) generates a sequence of numbers from 202 to 320. The correct condition to
check, if a number is divisible by 7 but not a multiple of 5, is i % 7 == 0 and i % 5 != 0.
for i in range(202, 321):
if i % 7 == 0 and i % 5! 0:
print(i)
Q No: 8
What will be the output of the following Python code?
Marks: 1/
for i in range(202, 321):
if i % 7 == 0 and i % 5 == 0:
print(i)
st = "Data Science"
count = 0
for i in st:
if i == "a" or i == "e" or i == "i" or i == "o" or i == "u":
Correct Answer