Search Header Logo

Python Training 3

Authored by Devanjali Relan

Computers

Professional Development

Used 1+ times

Python Training 3
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

def func(a, b=5, c=10):

    return a + b + c

 

print(func(1, 2))

13

 

8

18

3

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

def add_items(items, lst=[]):

    for item in items:

        lst.append(item)

    return lst

 

print(add_items([1, 2, 3]))

print(add_items([4, 5]))

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

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

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

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

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

x = (i for i in range(5))

print(next(x))

print(next(x))

print(next(x))

0, 1, 2

1, 2, 3

0, 1, 1

Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

d = {'a': 1, 'b': 2, 'c': 3}

d['d'] = 4

print(d)

{'a': 1, 'b': 2, 'c': 3}

{'a': 1, 'b': 2, 'c': 3, 'd': 4}

{'d': 4, 'a': 1, 'b': 2, 'c': 3}

Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

def func(a, b):

    return a * b

 

x = map(func, [1, 2, 3], [4, 5, 6])

print(list(x))

[4, 10, 18]

[4, 5, 6]

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

Error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

x = [i for i in range(10) if i % 2 == 0]

print(x)

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

[0, 2, 4, 6, 8]

[1, 3, 5, 7, 9]

Error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

def func(*args):

    return sum(args)

 

print(func(1, 2, 3, 4))

10

(1, 2, 3, 4)

[1, 2, 3, 4]

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?