To create a variable we just need to come up with a meaning full name. Python requires some basic formatting rules, variables need to start with with a letter though can contain numbers, they cannot contain spaces. Note variables are case sensitive.
PEP 8 underscores are typically used between words in variables in python. For example a variable for a welcome message could be defined in the following way.
welcome_message = "Welcome to my site about python"
If we want to change this message we can use redefine it contents.
welcome_message = "Welcome to my site about python" # update welcome message welcome_message = "Welcome to my site about Python and Java" print (welcome_message)
or pages views could be defined :
page_views = 12
This allows us to operate on the variable.
page_views = 12 # Increase the page view due to new visitor page_views += 1 print (page_views)
This returns the value "13".
Now you have an understanding of variables lets look at datatypes
Related Sections
Python - Learn the python from the basics up. This fast track example code course will get you creating powerful python programs in no time.Tkinter - Learn the key features of the tkinter to allow you to create user interfaces for your python programs.
Related Pages
Pickle - The pickle library allows a program to save data in a binary file.Python - List Comprehension - Create powerful list comprehension expressions.
Python - Generators - Learn about generator statements.
Python - Data types - The learn about the key datatypes in the python language.
Tkinter - Combo Box - This is a short example showing how to use combo boxes in a GUI.
Tkinter - Radio Buttons - A short example of how to create a GUI with radio buttons.
Tkinter - Canvas - Canvas allows for a range of shapes to be plotted, such as circles, squares, lines