InfyTQ Functions (Python) Quiz 1

Question 1

Time: 00:00:00
Which of the following statements is true?

Functions are used to create objects in Python.

Functions are used to create objects in Python.

Functions make your program run faster.

Functions make your program run faster.

A function is a piece of code that performs a specific task

A function is a piece of code that performs a specific task

All of the above

All of the above

Question 2

Time: 00:00:00
When a function is defined inside a class, what is called?

Class

Class

Modules

Modules

Another Function

Another Function

Method

Method

Question 3

Time: 00:00:00

def hope(text):
print(text, 'is awesome.')
hope('Prepinsta')

Predict output.

Prepinsta

Prepinsta

Prepinsta is awesome.

Prepinsta is awesome.

The text is awesome.

The text is awesome.

is awesome.

is awesome.

Question 4

Time: 00:00:00
 If return statement is not used inside the function, the function will return:

None object

None object

An arbitrary integer

An arbitrary integer

Error

Error

Function must return something

Function must return something

Question 5

Time: 00:00:00
What is a recursive function?

A function that calls all the functions in the program.

A function that calls all the functions in the program.

A function that calls itself.

A function that calls itself.

A function that calls all the functions in the program except itself.

A function that calls all the functions in the program except itself.

There is no such thing as a recursive function in Python.

There is no such thing as a recursive function in Python.

Question 6

Time: 00:00:00
The output of the following code will be:
output = lambda var: var * var

print(output(5))

10

10

5

5

25

25

5*5

5*5

Question 7

Time: 00:00:00

numbers = [1, 3, 6]
newNumbers = list(map(lambda x: x , numbers))
print(newNumbers)


Predict the output

[1, 3, 6]

[1, 3, 6]

[0, 1, 2]

[0, 1, 2]

1, 3, 6

1, 3, 6

0, 1, 2

0, 1, 2

Question 8

Time: 00:00:00

My_String = "Prep Insta"
My_String = My_String.split()
k = [(z.upper(), len(z)) for z in My_String]
print(k)

[(‘P’, 1), (‘r’, 1), (‘e’, 1), (‘p’, 1), (‘ ‘, 1), (‘I’, 1), (‘n’, 1), (‘s’, 1), (‘t’, 1), (‘a’, 1)]

[(‘P’, 1), (‘r’, 1), (‘e’, 1), (‘p’, 1), (‘ ‘, 1), (‘I’, 1), (‘n’, 1), (‘s’, 1), (‘t’, 1), (‘a’, 1)]

[('PREP', 4), ('INSTA', 6)]

[('PREP', 4), ('INSTA', 6)]

[('PREP', 4), (‘ ’, 1), ('INSTA', 5)]

[('PREP', 4), (‘ ’, 1), ('INSTA', 5)]

[('PREP', 4), ('INSTA', 5)]

[('PREP', 4), ('INSTA', 5)]

Question 9

Time: 00:00:00
What will be the output of the following Python code snippet?

print([z.lower() for z in "HELLO"])

['h', 'e', 'l', 'l', 'o']

['h', 'e', 'l', 'l', 'o']

hello

hello

Hello

Hello

hELLO

hELLO

Question 10

Time: 00:00:00

a = lambda i,j : i+j
print(a(5, 6))


What will be the output of the above code?

Error

Error

11

11

00

00

5,6

5,6

null
null