ExamVeda
Login
Home
11
What will be the output of the following Python function?
any([2>8, 4>2, 1>2])
Discuss
Answer & Solution
Answer: Option B
Solution:
The any() function in Python returns True if at least one element of the iterable is true, otherwise it returns False.
In the provided code, the list [2>8, 4>2, 1>2] contains three boolean expressions:

2>8 evaluates to False.
4>2 evaluates to True.
1>2 evaluates to False.
Since at least one of the expressions (4>2) is true, the any() function returns True.
12
What will be the output of the following Python function?
hex(15)
Discuss
Answer & Solution
Answer: Option D
Solution:
The hex() function in Python is used to convert an integer to a lowercase hexadecimal string prefixed with '0x'.
When you pass the integer 15 to the hex() function, it returns the hexadecimal representation of 15, which is '0xf'.
13
The function divmod(a,b), where both 'a' and 'b' are integers is evaluated as:
Discuss
Answer & Solution
Answer: Option B
Solution:
The correct answer is Option B: (a//b, a%b).
The divmod() function in Python returns a tuple containing the quotient and remainder when dividing 'a' by 'b', where both 'a' and 'b' are integers.
So, when evaluated, it returns (a//b, a%b), where 'a//b' represents the quotient and 'a%b' represents the remainder.
14
What will be the output of the following Python expression?
round(4.576)
Discuss
Answer & Solution
Answer: Option B
Solution:
The correct answer is Option B: 5.
The round() function in Python is used to round a floating-point number to the nearest integer.
When you pass 4.576 to the round() function, it rounds it to the nearest integer, which is 5.
15
What does the built-in function hex() do in Python?
Discuss
Answer & Solution
Answer: Option A
Solution:
The correct answer is Option A: Converts an integer to a hexadecimal string.
The hex() function in Python is used to convert an integer to a lowercase hexadecimal string.
For example:
print(hex(15))  # Output: '0xf'
print(hex(255)) # Output: '0xff'
16
What is the output of the following code:
my_list = [True, False, True]
print(any(my_list))
Discuss
Answer & Solution
Answer: Option A
Solution:
The any() function in Python returns True if at least one element of the iterable is true, otherwise it returns False.
In the provided code, the list [True, False, True] contains at least one True value, so the any() function returns True.
17
What will be the output of the following Python expression?
round(4.5676,2)?
Discuss
Answer & Solution
Answer: Option C
Solution:
The correct answer is Option C: 4.57.
The round() function in Python is used to round a floating-point number to a specified number of decimal places.
When you call round(4.5676, 2), it rounds the number 4.5676 to 2 decimal places, resulting in 4.57.
18
What will be the output of the following Python function?
float(‘-infinity’)
float(‘inf’)
Discuss
Answer & Solution
Answer: Option A
Solution:
The float() function in Python is used to convert a string or a number to a floating-point number.
When you pass the string 'inf' to the float() function, it returns positive infinity.
When you pass the string '-infinity' to the float() function, it returns negative infinity.
19
What will be the output of the following Python function?
all(3,0,4.2)
Discuss
Answer & Solution
Answer: Option C
Solution:
The correct answer is Option C: Error.
The all() function in Python expects a single iterable as its argument, but in the provided code, it is given multiple arguments (3, 0, and 4.2) instead of a single iterable. This will raise a TypeError.
20
What is the output of the function complex()?
Discuss
Answer & Solution
Answer: Option B
Solution:
The correct answer is Option B: 0+0j.
The complex() function in Python is used to create a complex number.
When no arguments are passed, it returns 0 as the real and imaginary parts, resulting in the complex number 0+0j.