IndexPythonJapaneseChainmailleLeather

Variables

  Variables store data under a name to be accessed later. They can be set in the program as a fixed value, as the result of an expression, or by prompting the user for input.
  In Python, variable names must start with a lower case letter or underscore. Variables can contain only letters, digits, and underscores.
   Camel Case: the first word starts with a lower case letter and subsequent words start with an upper case letter.
    I.E. birthYear, thisIsCamelCase
   Snake Case: all letters are lower case with words separated by an underscore.
    I.E. birth_year, this_is_snake_case
 Note: When using variables in expressions, be conscious of the variables' data types. For example, trying to subtract a string and an integer will result in an error.

  Examples:

   Initializing/setting a variable:
    a = 5
    name = "Craig"
    pi = 3.14

   Setting a variable as the result of an expression:
    b = 5 + 6

   Storing the result of an expression involving variables:
    c = a + b

   Prompting for user input and store as a variable:
    d = input("How old are you?")


HomeData TypesVariablesFunctionsEscape SequencesProgram Comments