0
0
Pythonprogramming~5 mins

Math-related operations 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 do you calculate the power of a number in Python?
You can use the ** operator or the pow() function. For example, 2 ** 3 or pow(2, 3) both give 8.
Click to reveal answer
intermediate
What is the difference between // and / operators in Python?
/ does normal division and returns a float. // does floor division and returns the largest whole number less than or equal to the result.
Click to reveal answer
beginner
How can you get the remainder of a division in Python?
Use the modulo operator %. For example, 7 % 3 gives 1 because 7 divided by 3 leaves a remainder of 1.
Click to reveal answer
beginner
What does the round() function do?
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
What is the output of abs(-10) in Python?
A-10
B0
C10
DError
Which operator gives the remainder of a division?
A%
B//
C/
D**
What does 5 // 2 return?
A2
B3
C2.5
D1
How do you calculate 3 to the power of 4 in Python?
A3 ^ 4
B3 ** 4
Cpow(4, 3)
D3 % 4
What does round(3.14159, 2) return?
A3.15
B3.1
C3
D3.14
Explain how to perform division and get both the quotient and remainder in Python.
Think about how to get the whole number part and the leftover part separately.
You got /4 concepts.
    Describe how to use Python functions and operators to calculate powers and absolute values.
    Remember the symbols and function names that help with these math operations.
    You got /4 concepts.