Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Identifier:

A name in python program is called a identifier

We have to use names to identify variable or to identify methode/function.that names itself called
as identifiers.

Item_name=”python” # variable name, i.e. also an identifier, and here (identifier) name tell us we

Store item in the variable.

Item_qty=10

Item_sale=230 //here item name are name (or identifier of the variable)

Rules for idenfier:


1)Only allowed characters a-z, A-Z, 0-9, underscore(_)

For example:

Age_man=30 #valid

@geman=54 #invalid(because @ symbol are not allowed here)

2)Identifier should not start with number or digits in any programming language.

For example:

Marks10=84 #valid

10marks=85 #invalid

3).Python identifiers are case sensitive.(like different name of a variable is consider as a different
variable.like: if you use car variable, so you may not take this variable again in Car name, you have to
take again this variable with same name as you first give car.)

For example:

//IT WILL CONSIDER DIFFERENT NAME OF VARIABLE, A DIFFERENT VARIABLE.

Marks=11 #THIS ONE IS DIFFERENT ,FIRST LETTER IS CAPITAL

marks= 22 #THIS ONE IS DIFFERENT, ALL ARE IN LOWER CASE.

MARKS=24

4)There is no length limit. But its not recommend to take too lengthy identifier. Remember the name
of the identifier should be reflecting the purpose of the identity.

5) In python, we can’t use reserved words as identifiers.(variable name)


Keywords/reserved words:
The words which are reserved to represent some meaning or functionalites, (int , float you can’t
take this is an variable because both are the reserved word), such type of words are called reserved
words or keywords.

-In python is 33 reserved words are available and in c 32 reserved keywords.

-List of Python keyword:

True, False, None, and, or, not, is, if, elif, else, while, for, break, continue, return, in , yield, Try,
except, finally, raise, form, as, class, def, pass.

Note: keywords are contains only alphabet symbols.

Like: only 3 keywords have the upper case(first letter). All others contains have lower case.

True False None

Example: a=true #error, because true is a reserve word and first letter is always capital

A=True #valid

-switch concept is not is python.

-Do while loop is not in the python.

-Int, float, etc. data type are not required in python to declare a variable. That’s why they are not
available in python keyword list.

Example: to get keywords list from python library.

Import keyword #here we import add our module (keyword) form python library

Keyword.kwlist #modulename.keywordlist
Built-in Data types

What is datatype:
-The name data type is represents, the type of data (i.e. that data
must be integer type, float type, long type etc…)
-The type of data (like:1) stored inside a variable.
For example:
10 - int type
100.50 - float type
True or False - Boole type or Boolean type.
-The data types are represents the type of data like: we choose
any kind of data for our program( i.e. that data must be pre-
defined in your program).
-Python is completely object oriented. (i.e. it maintain the real
time data like: it will used to develop real time project (car etc..)
-You do not need to declare(i.e. no need to defined that your
data is an integer type.)
-Every variable in python is an object.(object is model of your
variable ) and variable will work according to your object.

In python basic data types are 14


i.e-
int, float, comples, bool, str, list, tuple, set, frozenset, dict, bytes,
bytearray, range and none.
For example:
A = 100 # A is an variable, we take 100 object. And the class is
Int(integer type)

Here some most commonly used in-build function are:

Built-in function Description


type(a) Tell which type of data is store in variable.
Isinstance(100,int) To check 100 is an integer type of data or not, or
Object is belong to a particular class or not.
Id(a) Used to know the address of the object(11) in
Memory.
Print(a) Used to print the value of a and used to give the
Output, and used to display the text on the
Screen.
-

You might also like