Examveda

What will be the output of the following Python function?
float(‘-infinity’)
float(‘inf’)

A. -inf
inf

B. -infinity
inf

C. Error
Error

D. Error
Junk value

Answer: Option A

Solution (By Examveda Team)

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.

This Question Belongs to Python Program >> Python Built In Functions

Join The Discussion

Related Questions on Python Built In Functions