Solution
A variable is a storage container in a computer's memory, that allows storage, retrieval and manipulation of data. The value of a variable can change throughout the execution of a program:
PYTHON
age = 71
print("Ahmad lived for", age, "years")
age = 60
print("Iqbal lived for", age, "years")
Variable names in Python must begin with a letter or an underscore. Later characters can be letters, digits, or underscores. Names are case-sensitive, and reserved keywords such as for, while, and if cannot be used as variable names.
Common types include:
- Integer (
int): whole numbers, for exampleage = 17 - Floating-point (
float): decimal numbers, for exampleprice = 19.99 - String (
str): text, for examplename = "Ali" - Boolean (
bool):TrueorFalse, for exampleis_student = True