Anything (that isn't a Python keyword like
def) that starts with a letter or an underscore and contains only letters, numbers, and underscores is a legal variable name.
asdfahsldkfjh = 5 #legal variable name
Guidelines: make the variable names comprehensible -- prefer using words to abbreviations and initialisms.
num_coffee_cups = 2 #readable ncc = 2 #a future reader won't be able to figure it out easily (not moral, like jaywalking) x = 2 #very rarely justifibale (not really moral at all)
PI = 3.14159265359
Another example of a constant is a value that is not supposed to change. For example, in a program that has to do with EngSci courses, we might set
N_COURSES_ENGSCI = 6
Python will not prohibit us from changing values defined in all-uppercase:
PI = PI*1.01 #perfectly legal
However, a variable's name being all-uppercase suggests to the programmer that a line like the one above is likely a mistake.