Vidyalelo
Python · Q6

Python Built

Programming · Python · question 6

Q6

Which built-in function is used to convert a value to an integer?

A.
int()
Answer
B.
integer()
C.
to_int()
D.
convert_int()

Answer: Option A

Solution

Answer: Option A
Solution:
The correct answer is Option A: int().
The int() function in Python is used to convert a value to an integer.
It can convert a string representing a number, a float, or even another integer to an integer data type.
For example:
num_str = "10"
num_float = 3.14
converted_str = int(num_str)
converted_float = int(num_float)
print(converted_str)     # Output: 10
print(converted_float)   # Output: 3