Search Header Logo

Python test 3

Authored by Quốc Thư

Computers

8th Grade

Used 11+ times

Python test 3
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

30 sec • 1 pt

What is the output of the following code?

x = 10

if x > 5:

........x = x + 1

elif x == 10:

........x = x + 2

else:

........x = x + 3

print(x)

11

12

13

10

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the code below?

def calculate(a, b):

........if a > b:

................return a - b

........else:

................return b - a

x = calculate(5, 10)

print(x)

5

-5

0

Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output?

lst = [2, 3, 4]

for i in range(len(lst)):

........lst[i] += 1

print(lst)

[2, 3, 4]

[3, 4, 5]

[2, 4, 6]

Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

n = 5

fact = 1

while n > 0:

.........fact *= n

.........n -= 1

print(fact)

120

24

60

0

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the following function return? def mystery(x):

.........return x * x - 2 * x + 1

print(mystery(4))

9

4

1

16

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What is the result?

inner outer

outer inner

inner inner

outer outer

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which output is correct?

numbers = [1, 2, 3, 4, 5]

result = list(map(lambda x: x * x, numbers))

print(result)

[2, 4, 6, 8, 10]

[1, 4, 9, 16, 25]

[1, 2, 3, 4, 5]

Error

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?