GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.dremendo.com — Assignment Operators in Python Programming | Dremendo
?>
Announcements
No new announcements.
Python Programming Tutorial
Table of Contents
Assignment Operators in Python ProgrammingIn this lesson, we are going to look at what is assignment operator and will learn the different types of assignment operator with the help of examples. What is Assignment OperatorAssignment Operator in Python is used for assigning value to a variable. Using the assignment operator we can assign the value which is on the right side of the operator to the variable on the left side of the operator.
Video Explanation
Click the button below to watch the explanation.
Please wait while the video is loading....
Let's discuss about the different types of assignment operators with examples. Assign Operator =The Assign Operator = is used to assign a value to a variable. It takes the value on its right-hand side and assigns it to the variable on its left-hand side.
Example
As you can see the value 5 which is on the right side of the operator = has been assigned to the left in the variable a. In the same way value of the variable a (5) which is on the right side of the operator = has been assigned to the left in the variable b Add and Assign Operator +=The Add and Assign Operator += is a combination of + and = operators. This operator adds the value of the right-hand operand to the left-hand operand and then assigns the result back to the left-hand operand. It is a shorthand way to perform addition and assignment in a single step.
Example
Subtract and Assign Operator -=The Subtract and Assign Operator -= is a combination of - and = operators. This operator subtracts the value of the right-hand operand from the left-hand operand and then assigns the result back to the left-hand operand. It is a shorthand way to perform subtraction and assignment in a single step.
Example
Multiply and Assign Operator *=The *= operator is a combination of * and = operators. This operator multiplies the value of the left-hand operand by the right-hand operand and then assigns the result back to the left-hand operand. It is a shorthand way to perform multiplication and assignment in a single step.
Example
Divide and Assign Operator /=The /= operator is a combination of / and = operators. This operator divides the value of the left-hand operand by the right-hand operand and then assigns the result back to the left-hand operand. It is a shorthand way to perform division and assignment in a single step.
Example
Modulus and Assign Operator %=The %= operator is a combination of % and = operators. This operator calculates the remainder of the division of the left-hand operand by the right-hand operand and then assigns the result back to the left-hand operand. It is a shorthand way to perform modulus and assignment in a single step.
Example
Test Your KnowledgeAttempt the questions in the exercise to check whether you have understood the lesson clearly.
We care about your privacyDremendo uses cookies and similar technologies that are necessary for the site to work properly, understand how you interact with our website, and measure the effectiveness of our marketing. By clicking Accept All, you consent to the use of non-essential cookies and similar technologies for analytics, advertising, and ad measurement, as described in our Privacy Policy. Cookie PreferencesChoose which types of cookies Dremendo may use.
Necessary Cookies
Allow
Required for essential website functionality and security.
Analytics Cookies
Allow
Help us understand how visitors use Dremendo.
Marketing Cookies
Allow
Help us measure advertising performance and understand interactions with our advertisements.
Mentora
Question Asked: 0 / 20
Hi, I’m Mentora! I’m your personal AI tutor from Dremendo. Ask me anything, and I’ll help you understand it in a simple and easy way. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |