Python From Beginner to Advanced

0% completed

Previous
Next
Quiz
What is functional programming in Python?
A
A programming paradigm that treats computation as the evaluation of mathematical functions
B
A method of programming that emphasizes changing state and mutable data
C
A style of programming focused on the use of classes and objects
D
A technique primarily used for multi-threading applications
What does the following Python lambda function do?
result = (lambda x, y: x + y)(10, 20)
print(result)
A
Raises a syntax error
B
Outputs 30
C
Returns a function object
D
None of the above
What is the output of this code using the map() function?
nums = [1, 2, 3, 4]
result = list(map(lambda x: x * 2, nums))
print(result)
A
[2, 4, 6, 8]
B
[1, 2, 3, 4]
C
[0, 2, 4, 6]
D
TypeError
What is a generator function in Python?
A
A function that terminates immediately after it starts execution
B
A function that yields a sequence of results instead of a single value
C
A function that returns multiple values in the form of a tuple
D
A function used to generate and return a list
Examine the following code. What will be the output?
def countdown(num):
    while num > 0:
        yield num
        num -= 1

for x in countdown(3):
    print(x)
A
3 2 1
B
3 2 1 0
C
2 1 0
D
Error

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next