Python Programming Quiz

Python Programming Quiz

University

25 Qs

quiz-placeholder

Similar activities

Java Control and Loop -2

Java Control and Loop -2

University

20 Qs

C - Strings

C - Strings

University

20 Qs

Dynamic Programming DAA

Dynamic Programming DAA

University

20 Qs

Khối 1 - Đề kiểm tra môn Tin học

Khối 1 - Đề kiểm tra môn Tin học

1st Grade - University

20 Qs

Digital Logic Design

Digital Logic Design

University - Professional Development

20 Qs

Java Array

Java Array

University

23 Qs

Java Array

Java Array

University

21 Qs

Time and Space Complexity

Time and Space Complexity

University

20 Qs

Python Programming Quiz

Python Programming Quiz

Assessment

Quiz

Computers

University

Hard

Created by

ggukie ggukie

Used 1+ times

FREE Resource

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.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?