0
0
Pythonprogramming~5 mins

abs() and round() in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the abs() function do in Python?
The abs() function returns the absolute value of a number, which means it removes any negative sign and gives the distance from zero.
Click to reveal answer
beginner
How does the round() function work in Python?
The round() function rounds a floating-point number to the nearest whole number or to a specified number of decimal places.
Click to reveal answer
beginner
What will abs(-7.5) return?
It will return 7.5 because abs() removes the negative sign and returns the positive value.
Click to reveal answer
beginner
What is the result of round(3.14159, 2)?
It returns 3.14 because it rounds the number to 2 decimal places.
Click to reveal answer
beginner
Can round() be used without specifying decimal places? What happens then?
Yes, if you use round() without the second argument, it rounds the number to the nearest whole number (integer).
Click to reveal answer
What does abs(-10) return?
A10
B-10
C0
D-1
What is the output of round(4.678)?
A4.68
B5
C4.7
D4
Which function would you use to get the positive value of a number?
Aabs()
Bround()
Cint()
Dfloat()
What does round(2.345, 1) return?
A2.3
B2.4
C2.34
D3
If you want to round a number to zero decimal places, what should you do?
AUse round(number)
BUse abs(number)
CUse round(number, 0)
DUse int(number)
Explain how the abs() function works and give an example.
Think about how distance from zero is always positive.
You got /3 concepts.
    Describe how to use the round() function to round a number to 3 decimal places.
    Remember the second number tells how many digits after the dot you want.
    You got /3 concepts.