0
0
Pythonprogramming~20 mins

abs() and round() in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
Absolute and Rounded Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
1:30remaining
Output of abs() with negative float
What is the output of this Python code?
Python
value = -7.25
result = abs(value)
print(result)
ASyntaxError
B7.25
C7
D-7.25
Attempts:
2 left
๐Ÿ’ก Hint
abs() returns the positive distance from zero.
โ“ Predict Output
intermediate
1:30remaining
Output of round() with one decimal place
What is the output of this Python code?
Python
num = 3.14159
rounded = round(num, 2)
print(rounded)
A3.15
B3
C3.14
D3.1
Attempts:
2 left
๐Ÿ’ก Hint
round() rounds to the nearest value at the specified decimal place.
โ“ Predict Output
advanced
2:00remaining
Output of combined abs() and round()
What is the output of this Python code?
Python
value = -2.675
result = round(abs(value), 2)
print(result)
A2.67
B2.7
C2.6
D2.68
Attempts:
2 left
๐Ÿ’ก Hint
abs() removes the negative sign, then round() rounds the number.
โ“ Predict Output
advanced
2:00remaining
Output of round() with negative digits
What is the output of this Python code?
Python
num = 1234.5678
result = round(num, -2)
print(result)
A1200.0
B1300.0
C1234.0
D1235.0
Attempts:
2 left
๐Ÿ’ก Hint
Negative digits in round() round to tens, hundreds, etc.
๐Ÿง  Conceptual
expert
2:30remaining
Behavior of abs() and round() with complex numbers
What happens when you run this Python code?
Python
z = complex(-3, 4)
result = round(abs(z))
print(result)
A5
BTypeError
C7
DSyntaxError
Attempts:
2 left
๐Ÿ’ก Hint
abs() returns the magnitude of a complex number.