Variables in programming allow us to store values for later use.
everest_height = 8849
france_capital = "Paris"
euro_dollar_rate = 1.09
print("Height of Everest", everest_height)
print("Capital of France:", france_capital)
print("EURUSD on 23 May 2023:", euro_dollar_rate)
If you’re coming to Python from another programming language, note the following.
- In Python, variables are created just by assigning them a value. There are no special keywords used for declaring variables in Python, like the keywords my, var, int, and so on found in other programming languages.
- Variables do not have a type, so it isn’t necessary or possible to specify the type of a variable.
- All values in Python are objects, even literal integers, so Python variables are basically references to objects; they contain the locations of objects, allowing you to refer to those objects when you want.
- There are no true constants in Python.
Coding Conventions
A common convention is it use lower-case letters when inventing a name for a variable. If multiple words are used to form the variable name, separate them by underscores.
Other conventions are also used, but it’s important to follow a consistent convention when working on code.
Leave a Reply