Professional Documents
Culture Documents
BJHB 1-1
BJHB 1-1
Answer Key
Q1. Write a Python program that takes two numbers as input from the user and displays their sum.
Q2. Write a Python program that prompts the user to enter their name and displays a personalized
greeting message.
Q7. What is the difference between the int() and float() functions in Python?
The int() and float() functions in Python are used to convert values to integers and floating-point
numbers, respectively. The int() function converts a value to an integer, truncating any decimal part, while
the float() function converts a value to a floating-point number, preserving the decimal part if present.
Built-in functions in Python are essential as they provide ready-to-use functionality, eliminating the
need for writing complex code from scratch. They save time, improve code readability, and promote code
reuse.
Q9. Write a single program that contains all type conversion functions:
int(), str(), min(), max(), float(), eval(), abs(), type(), len(), range(), input()
# int()
print(int(3.14)) # Output: 3
print(int('42')) # Output: 42
# str()
print(str(123)) # Output: '123'
print(str(3.14)) # Output: '3.14'