iNTERFACEWARE Products Manual > Learning Center > Learning Python > Working With Values and Variables > Variables > Assignment |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
Python uses assignment to specify that a value is to be stored in a variable. The = symbol is used to represent an assignment. For instance, here is how you would store the number 42113 in the variable patientid:
This also works for strings. For example, to assign the string Admitted to the variable status, use this:
Note that the same variable can be used to contain either a number or a string, depending on what you assign to it. For instance, this Python code is perfectly valid:
You can assign the contents of one variable to another variable:
Because patientstatus contains Admitted, admissionstatus now also contains Admitted. Note that these are two separate copies of the value. For instance, suppose that you copy the value of one variable into another, and then change the value of the first variable:
Here, patientstatus now contains Waiting for results, but admissionstatus still contains Admitted. You can assign a value to more than one variable at once. For example, the following assigns 42113 to three variables:
|