Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning, Exams of Computer Science

Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning

Typology: Exams

2024/2025

Available from 08/12/2025

boom-amor
boom-amor 🇺🇸

358 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1/9
Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning
Course Content
Practice Quiz 1.4 - Looping Statements
Type : Practice Quiz
Attempts
:
1/1
Questions : 9
Time : 1h
Your
Marks : 10/10
Instructions
Attempt History
Attempt
#1
Nov 29, 2022, 3:46 PM
Marks: 10
Q No: 1 Correct Answer
Marks: 1/1
Which among the below snippets can be used to print all integers between -10 to -1 including
both -10 and -1?
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning and more Exams Computer Science in PDF only on Docsity!

Practice Quiz 1.4 - Looping Statements: Python - Foundations - Great Learning

Course Content

Practice Quiz 1.4 - Looping Statements

Type : Practice Quiz

Attempts : 1/

Questions : 9

Time : 1h

Your Marks : 10/

Instructions

Attempt History

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

  • 10 to - 1 is generated using range(start =-10, stop = 0, step_size = 1)

n = 10

i = 1

while i <= n:

print(i)

missing code

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):

missing code

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