Python Programming Quiz

Python Programming Quiz

University

10 Qs

quiz-placeholder

Similar activities

Linux Commands

Linux Commands

University

11 Qs

ACM-W linux workshop

ACM-W linux workshop

University

8 Qs

IT files types for gender neutral Apache helicopters

IT files types for gender neutral Apache helicopters

KG - Professional Development

13 Qs

Ms Word

Ms Word

University

10 Qs

Python Basics

Python Basics

1st Grade - University

9 Qs

Intro to PHP

Intro to PHP

12th Grade - University

15 Qs

TSSR - S03 - La gestion des utiisateurs

TSSR - S03 - La gestion des utiisateurs

University

8 Qs

Intermediate Python

Intermediate Python

University

15 Qs

Python Programming Quiz

Python Programming Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Adi Adi

FREE Resource

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

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?