Examveda

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

A. Converts an integer to a hexadecimal string

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 (By Examveda Team)

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'

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

Join The Discussion

Related Questions on Python Built In Functions