Saved Bookmarks
| 1. |
Explain assigning values to variables in Python. |
|
Answer» Python variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables. The operand to the left of the = operator is the name of the variable, and the operand to the right of the = operator is the value stored in the variable. For example: # !/usr/bin/python counter = 100 # An integer assignment miles = 1000.0 # A floating point name = “John” # A string print counter print miles print name while running this program, this will produce the following result: 100 1 000.0 John |
|