-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTest - Functions
71 lines (61 loc) · 1.7 KB
/
Test - Functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
1. Which keyword is used to define a function in Python?
a) method
b) def
c) function
d) define
2. What is the purpose of the lambda keyword in Python?
a) To define a class
b) To create a variable
c) To declare a function
d) To define an anonymous function
3. What does the len() function return when applied to a list in Python?
a) The sum of all elements in the list
b) The number of items in the list
c) The average of all elements in the list
d) The maximum value in the list
4. How do you call a function named my_function in Python?
a) call my_function()
b) my_function
c) invoke my_function()
d) my_function()
5. What is the return type of the range() function in Python?
a) Integer
b) List
c) Tuple
d) Range object
6. What does the map() function do in Python?
a) Applies a function to each element of an iterable
b) Filters out elements from an iterable
c) Computes the sum of all elements in an iterable
d) Sorts the elements of an iterable
7. Can a function in Python have multiple return statements?
a) Yes
b) No
c) Only if the function has a single parameter
d) Only if the function is defined using lambda
8. Can a function in Python have optional parameters?
a) Yes
b) No
c) Only if the function is defined using lambda
d) Only if the function has a single line of code
9. What is the scope of a variable defined inside a function in Python?
a) Global scope
b) Class scope
c) Function scope
d) Module scope
10. What is a recursive function in Python?
a) A function that calls itself
b) A function defined inside another function
c) A function that accepts a variable number of arguments
d) A function that returns a boolean value
Correct answers:
1. b)
2. d)
3. b)
4. d)
5. d)
6. a)
7. a)
8. a)
9. c)
10. a)