Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Arithmetic and Assignment Operator We use arithmetic operators to perform common mathematical operations on numerical values in Python. These operators include:

a. the Addition (+) operator, which adds two operands together. Note that in Python, the plus (+) symbol is known to be overloaded, meaning that it has multiple uses. It can be used to concatenate strings, among other things.

b. the Subtraction (-) operator is used to subtract the second operand from the first.

c. the Multiplication (*) operator is used to multiply two or more operands.

d. the Division (/) operator divides the first operand by the second and always returns a float (decimals).

e. the Modulus (%) operator returns the remainder of the division of the first operand by the second. That is, only the remainder of the value is used in this case.

f. the Exponentiation () operator is used to raise the first operand to the power of the second operand. Example 23 is the same as 222.

g. the Floor Division (//) operator divides the first operand by the second and rounds down the number to the nearest lower integer.

We also have the assignment operator used to assign values to variables. The assignment operator is denoted by the equals sign (=), which assigns the value on its right-hand side to the variable on its left-hand side, for example: amount = 100. There is the compound assignment operator, which is a shorthand way to modify a variable's value based on its current value. The following are examples of compound assignment operators: +=, -=, *=, /=, %= //=, **=, etc. The Python file attached shows examples of how these arithmetic operators are used.

About

A class task to find out the balance of a student's allowance for the week using arithmetic operators

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages