CS
  • Home
  • Languages
    • Python >
      • Basics
      • Conditions & Loops
      • Functions and Modules
      • Other Data Types
      • Errors and Exceptions
      • Projects
    • C + + >
      • Basics
      • Functions
      • Conditions & Loops
  • Programs
  • About

Assignment Operators

Shortcuts
When you create a variable and set it equal to a value the equal sign is called an assignment operator.
There are some operators the can evaluate an operation and assign a value at the same time.
​This shorthand operation is created by using a math operation and an equal sign next to each-other.

x += 12 is equal to x = x + 12
x %= 3 is equal to x = x%3
Note: The variable must have an initial value

    

​Other Types
This can also be used on Strings.
​Increments
This is very useful when we want to increase a variables value by increments.

    
Previous - Simple Math
Next - Format
Powered by Create your own unique website with customizable templates.
  • Home
  • Languages
    • Python >
      • Basics
      • Conditions & Loops
      • Functions and Modules
      • Other Data Types
      • Errors and Exceptions
      • Projects
    • C + + >
      • Basics
      • Functions
      • Conditions & Loops
  • Programs
  • About