Assigning a Variable with another Variable #
In Python, we can assign the value of one variable to another variable using the assignment operator =. The value on the right side of the operator is assigned to the variable on the left side. For example, if we have a variable x with the value 10, we can assign it to another variable y like this:
x = 10
y = x
Now the value of y is also 10. We can also reassign the value of x later, and it will not affect the value of y since it was only assigned the value of x at the time of assignment.
Exercise #
- Create a new variable
xand assign the number10to it. - Create another variable
yand assign the variablexto it.
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