0% found this document useful (0 votes)
3 views4 pages

Python Identifiers and Data Types

Python

Uploaded by

miglani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Python Identifiers and Data Types

Python

Uploaded by

miglani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

PYTHON SYNTAX:

==============
IDENTIFIERS
RESERVED WORDS
DATATYPES
VARIABLES
IO OPERATIONS
OPERATORS
TYPE CONVERSION

=========================================

IDENTIFIERS
===========

PVM ==> Python Virtual Machine

Interpreter

Python Software ==> Interpreter downloaded automatically

source code (.py) ====> Interpreter (PVM) =======> Object Code (.obj) ==> System
===> Output

==> IDENTIFER IN PYTHON USED TO NAME THE DATA/VALUE (VARIABLE) OF THE PROGRAM.
==> ALSO USED TO NAME OTHER ENTITIES LIKE:FUNCTIONS, CLASSES, OBJECTS ETC.

IDENTIFIER RULES:
=================
1) WHAT TO USE & WHAT NOT TO USE:
include: i) Alphabets (A-Z and a-z)
ii) Digits (0 to 9)
iii) Underscore sign (_)
not includes: i) space
ex: python name ==> Syntax Error
ii) special characters (@!~`#$%^,

2) EVERY IDENTIFIER SHOULD NOT START WITH A DIGIT


EX: 9a1bc = 10
BUT IT CAN BE ALLOWED TO START/BEGIN WITH ALPHABET OR UNDERSCORE SIGN.

3) IDENTIFIER SHOULD NOT WITH KEYWORDS. (NO KEYWORD AS AN IDENTIFIER)

4) PYTHON IDENTIFIERS ARE CASE SENSITIVE.

EX: rateOfInterest = 10
Rateofinterest
RATEINTEREST
rateinterest

5) NO LIMIT IN THE LENGTH OF THE IDENTIFIER

RESERVED WORDS:
===============
==> SMALL LANGUAGE
C == 32 KEYWORDS
PYTHON == 35 KEYWORDS
JAVA == 65
==> PRE-DEFINED WORD/KEYWORD
WHICH IS HAVING A PRE-DEFINED MEANING
==> for the selection:
if, else, elif
==> for the looping:
for, while

IN THE REAL TIME:


FOR ANY DEVELOPMENT:
WE SHOULD FOLLOW DOCUMENTATION

==========================================================================

PYTHON DATATYPES
================
DYNAMICALLY TYPED PROGRAMMING LNAGUAGE
==> based on the assignment of the value, the PVM can detect the type
automatically.
ex: a = 100
type(a) # int

EX: C/C++/JAVA:
a = 10
b = 12.23

C/C++ ==> BASED ON THE DATATYPE AND THE VALUE ASSIGNMENT


THE MEMORY FOR THE VALUE CAN BE TRIGGERED.
int a = 'A';
for the a ==> 4 bytes
char ch;
for ch ==> 1 byte

JAVA ==> STRONGLY TYPED


int a = 97.79f; ==> syntax error

DATATYPE:
=========
==> ALL THE DATATYPES IN PYTHON ARE INBUILT
==> FOR ALL THE DATATYPES: WE HAVE A PRE-DEFINED CLASS

type()
======
==> pre-defined method/inbuilt method
==> to know the type of the data/class name of the data.
Syntax:
type(value_name/Identifier/Value)
==> type() is not the write method
==> to display the type of the data:
we can nest the type() in print()
Syntax:
print(type(value/identifier))

print()
=======
==> write method/output method
==> to display anything on the screen
Syntax:
print(value/identifier/"text")

DIFFERENT DATATYPES IN PYTHON:


=============================
1) NUMERICAL TYPE ==> INTEGER, FLOAT AND COMPLEX
2) BOOLEAN TYPE ==> bool ==> True and False
3) TEXT TYPE ==> all character representations and String representations
4) COLLECTION TYPE ==>
SEQUENTIAL TYPE ==> List, Tuple ==> Index based
MAPPING TYPE ==> Key : Value ==> Dictionary
NON-SEQUENTIAL TYPE ==> Non-Index Based ==> Sets, Frozen Sets
BYTE TYPE ==> 0 to 255 ==> bytes, byte array

Note:
=====
No character data representation in Python
ex: 'a', "a", '''a''' ===> Text type

You might also like