PYTHON TRAINING 2

PYTHON TRAINING 2

University

20 Qs

quiz-placeholder

Similar activities

Intro to Visual Basic

Intro to Visual Basic

10th Grade - University

20 Qs

Let's Check!

Let's Check!

12th Grade - Professional Development

15 Qs

Refresh your HTML concepts

Refresh your HTML concepts

University

21 Qs

Mid Semester Simulasi Digital

Mid Semester Simulasi Digital

12th Grade - University

20 Qs

ทดสอบย่อย 3 หลักการเขียนโปรแกรม

ทดสอบย่อย 3 หลักการเขียนโปรแกรม

University

20 Qs

L73_118 Prep for Test

L73_118 Prep for Test

12th Grade - University

20 Qs

QUIZ 2 CO

QUIZ 2 CO

University

20 Qs

KIểm tra 15' - Lớp 6

KIểm tra 15' - Lớp 6

University

18 Qs

PYTHON TRAINING 2

PYTHON TRAINING 2

Assessment

Quiz

Computers

University

Hard

Created by

Devanjali Relan

Used 1+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What will be the output of the following code?

def func(a, b=[]):

    b.append(a)

    return b

 

print(func(1))

print(func(2))

[1], [2]

[1], [1, 2]

[1, 2], [1, 2]

[2], [1, 2]

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. Which of the following code snippets correctly creates a generator?

def generator():

    yield 1

    yield 2

def generator():

    return 1

    return 2

def generator():

    return [1, 2]

def generator():

    return (1, 2)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What is the output of the following code?

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

        return a * b

     

    print(multiply(5))

0

5

1

Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What is the result of the following code?

x = [1, 2, 3]

y = [4, 5, 6]

z = zip(x, y)

print(list(z))

[(1, 4), (2, 5), (3, 6)]

[(1, 2, 3), (4, 5, 6)]

[1, 4, 2, 5, 3, 6]

Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What is the output of the following code?

def foo(x, y):

    return x + y, x - y

 

result = foo(5, 3)

print(result)

(8, 2)

8, 2

[8, 2]

(8, -2)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What will be the output of the following code?

  2. def foo():

        try:

            return 1

        finally:

            return 2

     

    print(foo())

1

2

None

Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. What is the output of the following code?

x = [1, 2, 3, 4]

y = [i * i for i in x if i % 2 == 0]

print(y)

[1, 4, 9, 16]

[4, 16]

[2, 4]

[1, 3]

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?