Posts

Showing posts with the label python variable

What are Python variables with example -thefreegyan

Image
  Variable in Python Variables definition Variables are boxes for storing information values . Creating Variables Python has no command for putting forward a variable. A variable is created the instant you first assign a cost to it. Example : x = 5 y = "John" print(x) print(y)  x is a variable ok. Variable names  A variable can have a short name (like x and y) or a more descriptive name (age, autoname, total volume) Rules for Python variables: A variable name must start with a letter or the underscore character A Variable name cannot start with a number beginA variable name can only contain alphanumeric characters and underscores (A-z, 0-9 and _). Variable names are case sensitive (age, Age and AGE are three different variables) Example : myvar = "John" my_var = "John" _my_var = "John" myVar = "John" MYVAR = "John" myvar2 = "John" print(myvar) print(my_var) print(_my_var) print(myVar) print(MYVAR) print(myvar2) Many ...