Search Header Logo

Python Programming Quiz

Authored by Adi Adi

Computers

University

Python Programming Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? x = 5 if x > 3: print('Hello') else: print('Hi')

Hello

Hey

Goodbye

Hi

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? for i in range(3): print(i)

0 1 2

1 2 3

1 2

0 1 3

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? file = open('data.txt', 'r') print(file.read()) file.close()

The file 'data.txt' does not exist.

An error will occur because the file is not opened in read mode.

The contents of the 'data.txt' file will be printed.

The code will print the file object instead of its contents.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? x = 10 while x > 0: print(x) x -= 2

10 8 6 4 2 0

10 8 6 4 2

10 8 6 4 2

10 8 6 4

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? x = 5 if x < 0: print('Negative') elif x == 0: print('Zero') else: print('Positive')

Positive

None

Zero

Negative

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? for i in range(1, 5): if i == 3: continue print(i)

1 2 3 4

1 2 4

1 2 3

1 2 4

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? file = open('data.txt', 'w') file.write('Hello') file.close()

Hello

data.txt

True

None

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