Search Header Logo

Python Programming Quiz

Authored by ggukie ggukie

Computers

University

Used 1+ times

Python Programming Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement corrects the off-by-one error in the following code: # This code prints the first 10 numbers starting with zero i = 0 while i <= 10 : print(i) i = i + 1

Replace |i = 0| with |i = 1|

Replace |while i <= 10| with |while i < 10|

Replace |i = i + 1| with |i = i + 2|

Replace |while i <= 10| with |while i + 1< 10|

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many times will the following loop run? i = 0 while i < 10 : print(i) i = i + 1

|0|

|8|

|9|

|10|

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the code snippet given below? i = 0 while i != 9 : print(i, end = " ") i = i + 2

No output

0 2 4 6 8

10 12 14 16 18 ... (infinite loop)

0 2 4 6 8 10 12 14 ... (infinite loop)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many times does the code snippet given below display "Loop Execution"? i = 1 while i != 10 : print("Loop Execution") i = i + 1

Infinite times

8 times

9 times

10 times

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the code fragment given below? i = 0 j = 0 while i < 27 : i = i + 2 j = j + 1 print("j =", j)

|j = 27|

|j = 12|

|j = 13|

|j = 14|

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code snippet? i = 1 while i < 10 : print(i, end = " ") i = i + 2 if i == 5 : i = 9

1 3 5

1 3 9

1 3 5 7 9

1 3 5 9

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The code snippet below is supposed to check whether an integer greater than 1 is a prime number. What will be the result of executing it? j = 2 result = 0 number = int(input("Please enter an integer (2 or greater):")) while j < number : if number % j == 0 : result = 1 j = j + 1 if result == 1 : print("Number:", number, "is Not Prime.") else : print("Number:", number, "is Prime.")

The code snippet contains a compile error.

The code snippet displays the desired result.

The code snippet displays an incorrect result.

The code snippet causes an infinite loop.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers