Vous êtes sur la page 1sur 7

Python Character set

1. All letters(uppercase and lowercase)


2. All digits
3. All white spaces( tab, return/enter, shift,etc)
4. All special symbols (!@#$%^&*(_+)
5. All other ASCII (American Standard for
Information Interchange) and Unicode characters
Advantages of Python
1. Easy to use
2. Expressive
3. Compatible across all platforms
4. Interpreter not a compiler
5. Has a variety of applications
6. Free and Open Source
7. Dont need to download libraries
Disadvantages of Python
1. Not as fast as Java/Perl
2. Libraries not as large and vast as C++
3. not easily convertible to other languages
4. Not strong on type binding
Tokens
Smallest unit of a programming language
1. Literals
2. Punctuators
3. Operators
4. Keywords
5. Idenitfiers
Keywords
1.
Special words used in python which have a
pre-defined function

2.

Eg. Global, lambda

Identifiers(How to name)
1. Cannot have a keyword
2. Cannot start with a digit
3. All digits and all letters can be used
4. No special symbols except the _ can be used.
5. Can be unlimited length
Literals
Different types
1. String Literals
2. Numeric Literals
3. None(Special)
4. Collection(Lists, tuples)
5. Boolean
1. String
String literals are literals which are strings, ie.
Enclosed with or
There is a special function len() to determine the
length of the literal
For single line literals, len includes all the spaces
along with all the characters
For multi line strings, len() counts even the
character (blank space at the end of the word) This
can be avoided if one puts \ a backslash at the
end of the word/line

Multi line strings can be either created by putting


triple quotes, or by going to last character in a line
and putting a backslash.
2. Numeric Literals
Contains 4 parts:1. Plain integer(int)(4 bytes only)
Plain is further divided into
1.Decimal integer literals
2.Octal integer literals(represented as
0_____(octal integer)
3. Hexadecimal literals are represented by
0X________
2. Float integer(which has a fractional part, upto
15 precision digits)
1. Fractional Form
xxxx.yyyyy.
No x (decinal point has to be included)
x. (No digit after decimal)
x/y (/ not allowed)
x.x.y
x,xx.y(No comma allowed)
2. Exponent Form
0.58 = 0.58E01= 5.8E-01=58E-02
3.Boolean
True/False has values(1/0)
4. None

Used when we have to assign a variable a


certain value, but cant, so we use None for the
time being.
3. Operators
There are different kinds of operators:i)
Unary
a) +a Just gives the value
b)a Gives the value and changes the
sign
c) Bitwise Complment
d)Not Logical Negation
ii) Binary Operators
Handles 2 operators
a) Arithmetic operators +-/*% ** //
b)Bitwise Opertors
a. Bitwise OR(XOR) ^
b. Bitwise AND &
c. Bitwise OR |
c) Shift Operators
a. >>> Shift right, divides
binary by 2
b. <<< Shift left, multiplies
binary by 2
d)Identity Operators
a. is
b. is not
e) Relational Operators
Compares 2 quantitites
a. < Less thab
b. > Greater than
c. == Equal to

f) Assignment Operators
Combines 2 operatores
a. a += n is the same as a
= a+n
b. a -= n is the same as a =
an
g)Logical Operators
a. and
b. or
h) Membership Operators
a. in
b. not in
4. Punctuators
Used to organize programming structures

Long integer(L,,8 bytes,) If 3 is integer, 3L


Complex integer. Has a real and imaginary part.
Real is represented by z.real and the imaginary
part is represented as z.imag. Here, instead of i, j
or J is used..

Vous aimerez peut-être aussi