Naming rules for identifiers
Variables are examples of identifiers. An identifier is a name used to identify something. When naming identifiers, you should follow these rules:
the first character of an identifier must be a letter in the alphabet (uppercase or lowercase) or an underscore (' _ ').
other parts of the identifier name can consist of a letter (uppercase or lowercase), an underscore (' _ '), or a number (0-9).
The identifier name is case-sensitive. For example, MyName and myname are not an identifier. Note that the former lowercase n and
the latter in uppercase N.
Examples of valid identifier names are I, __my_name, name_23, and A1B2_C3.
examples of invalid identifier names are 2things, this was spaced out, and My-name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
variable can handle different types of values, called data types. The basic types are numbers and strings, and we've talked about them. In the later chapters of
, we will look at how to create our own types using classes.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
object
Remember that Python calls anything that is used in a program as an object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments to object-oriented programming users
Python is extremely completely object-oriented to
objects, including numbers, strings, and even functions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How to write a python program
The following are standard procedures for saving and running Python programs.
1. Open your favorite editor.
2. Enter the program code in the example.
3. Save it as a file with the file name given in the note. I follow the convention of saving all Python programs with the
extension. py.
4. Run the interpreter command Python program.py or use the idle run program. You can also use an executable method that was previously referred to as
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An example of
using variables and literal constants
# Filename:var.pyi = 5print= i + 1print"This isa multi-line String. The second line. " " Print S
Variables-Data types-objects-how to write Python scripts