Vidyalelo
Python · Q15

Python Built

Programming · Python · question 15

Q15

What does the built-in function hex() do in Python?

A.
Converts an integer to a hexadecimal string
Answer
B.
Converts a string to lowercase
C.
Returns the square of a number
D.
Returns the absolute value of a number

Answer: Option A

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'