What will be the output of the following Python function?
float(' -12345\n')
(Note that the number of blank spaces before the number is 5)
float(' -12345\n')A. -12345.0 (5 blank spaces before the number)
B. -12345.0
C. Error
D. -12345.000000000.... (infinite decimal places)
Answer: Option B
Solution (By Examveda Team)
The correct answer is Option B: -12345.0.The float() function in Python is used to convert a string or a number to a floating-point number. When you pass the string ' -12345\n' (which includes leading and trailing whitespace characters) to the float() function, it strips the leading and trailing whitespace and converts the remaining characters to a floating-point number. In this case, it converts '-12345' to a float, resulting in -12345.0.
Which built-in function is used to find the smallest item in an iterable?
A. min()
B. smallest()
C. minimum()
D. small()
What does the built-in function round() do in Python?
A. Rounds a floating-point number to the nearest integer
B. Returns the square of a number
C. Returns the absolute value of a number
D. Converts a number to a string
What does the built-in function max() do in Python?
A. Returns the largest item in an iterable
B. Converts a number to a string
C. Returns the square of a number
D. Returns the absolute value of a number
Which built-in function is used to check if all elements in an iterable are true?
A. all()
B. every()
C. true()
D. check()

Join The Discussion