Prasanna

Basics of Python – Variable, Identifier and Literal

In this Page, We are Providing Basics of Python – Variable, Identifier and Literal. Students can visit for more Detail and Explanation of Python Handwritten Notes Pdf.

Basics of Python – Variable, Identifier and Literal

Variable, identifier, and literal

A variable is a storage location that has an associated symbolic name (called “identifier”), which contains some value (can be literal or other data) that can change. An identifier is a name used to identify a variable, function, class, module, or another object. Literal is a notation for constant values of some built-in type. Literal can be string, plain integer, long integer, floating-point number, imaginary number. For e.g., in the expressions

var1=5 
var2= 'Tom'

var1 and var2 are identifiers, while 5 and ‘ Tom’ are integer and string literals, respectively.

Consider a scenario where a variable is referenced by the identifier a and the variable contains a list. If the same variable is referenced by the identifier b as well, and if an element in the list is changed, the change will be reflected in both identifiers of the same variable.

>>> a = [1, 2, 3]
>>> b =a 
>>> b 
[1, 2, 3]
>> a [ 1 ] =10
>>> a
[1, 10, 3]
>>> b
[1, 10, 3]

Now, the above scenario can be modified a bit, where a and b are two different variables.

>>> a= [1,2,3 ]
>>> b=a[:] # Copying data from a to b.
>>> b 
[1, 2, 3]
>>> a [1] =10 
>>> a 
(1, 10, 3]
>>> b
[1, 2, 3]

There are some rules that need to be followed for valid identifier naming:

  • The first character of the identifier must be a letter of the alphabet (uppercase or lowercase) or an underscore (‘_’).
  • The rest of the identifier name can consist of letters (uppercase or lowercase character), underscores (‘_’), or digits (0-9).
  • Identifier names are case-sensitive. For example, myname and myName are not the same.
  • Identifiers can be of unlimited length.

Python Programming – Introduction to Python

In this Page, We are Providing Python Programming – Introduction to Python. Students can visit for more Detail and Explanation of Python Handwritten Notes Pdf.

Python Programming – Introduction to Python

Open-source software

Before stepping into the world of programming using open source tools, one should try to understand the definition of open-source software given by “Open Source Initiative” (abbreviated as OSI). OSI is a non-profit corporation with global scope, formed to educate about and advocate the benefits of open source software, and to build bridges among different constituencies in the open-source community.

Open-source software is a defined as software whose source code is made available under a license that allows modification and re-distribution of the software at will. Sometimes a distinction is made between open source software and free software as given by GNU {http://www.gnu.org/). The detailed distribution terms of open-source software given by OSI are given on the website link: http://opensource. org/.

Python(x,y)

“Python(x,y)” is a free scientific and engineering development software for numerical computations, data analysis, and data visualization based on Python programming language and Spyder interactive development environment, the launcher (current version 2.7.6.0) is shown in figure 1-5. The executable file of Python(x,y) can be downloaded and then installed from the website link: http://code.google.eom/p/pythonxy/. The main features of Python(x,y) are:

  • Bundled with scientific-oriented Python libraries and development environment tools.
  • Extensive documentation of various Python packages.
  • Providing an all-in-one setup program, so that the user can install or uninstall all these packages and features by clicking one button only.

Python Handwritten Notes Chapter 1 img 5

EBNF

A “syntactic metalanguage” is a notation for defining the syntax of a language by the use of a number of rules. A syntactic metalanguage is an important tool of computer science. Since the definition of the programming language “Algol 60”, it has been a custom to define the syntax of a programming language formally. Algol 60 was defined with a notation now known as “Backus-Naur Form” (BNF). This notation has proved a suitable basis for subsequent languages but has frequently been extended or slightly altered.

There are many different notations that are confusing and have prevented the advantages of formal unambiguous definitions from being widely appreciated. “Extended BNF” (abbreviated as EBNF, based on Backus-Naur Form) brings some order to the formal definition of the syntax and is useful not just for the definition of programming languages, but for many other formal definitions. Please refer international standard document (ISO/IEC 14977:1996(E)) for detailed information on EBNF (website link: http://standards.iso.org/ittf/PubliclyAvailobleStandards/).