Search Header Logo

PYTHON QUIZ-I

Authored by SRINIVASARAO 22PHD7042

Computers

University

Used 1+ times

PYTHON QUIZ-I
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

1.What is the output of the following code?

numbers = [1, 2, 3]

for num in numbers:

if num == 2:

break

print(num)

1

12

123

None

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

2.What is the output of the following code?

x = 10

if x > 5:

print("x is greater than 5")

else:

print("x is less than or equal to 5")

x is greater than 5

x is less than or equal to 5

Error

None

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

  1. 3.Which of the following statements is true about while loops in Python?

The loop executes a fixed number of times.

The loop executes as long as the condition is true.

The loop executes only once.

The loop condition is optional.

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

  1. 4.What is the output of the following code?

  2. def multiply(a, b=2):

  3. return a * b

  4. print(multiply(3))

6

3

Error

None

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

  1. 5.What is the correct way to open a file in write mode?

open('file.txt', 'r')

open('file.txt', 'w')

open('file.txt', 'rw')

open('file.txt')

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

6.Which of the following statements about Python functions is false?

Functions can return multiple values.

Functions can have default parameters.

A function must always have a return statement

Functions can be nested inside other functions.

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

7.What will be the output of this code?

x = 5 while x > 0: print(x, end=" ") x -= 1

5 4 3 2 1

5 4 3 2 1 0

5 4 3 2

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