Compound division #
Compound division is a shorthand way of dividing a variable by a given value and then assigning the result to the same variable. It uses the /= operator.
For example:
x = 5
x /= 2 # equivalent to x = x / 2
print(x) # Output: 2.5
Exercise #
- Rewrite the code on line 3 to use
/=to divide the value ofxand assign it back to the variablex - The value of
xshould be50
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules