Sie sind auf Seite 1von 9

keywords:

30words--in python
limitations of python:
1.performance (bcoz interpreted lanaguage)
2. Not used in Mobile applications
3.pYTHON IS NOT SUTABLE FOR LARGE SCALE ENTERPRSE APPLICATIONS

BENIFITS:
1.Simple to learn
2.free ware and open source
3.high level programming language
4.Platform independent
5.Portability
6.Dynamically Tyyped
7.Both Procedure oriented and object oriented
8.interpreted lnguGE
9.EXTENSIBLE
10. Embedded
11. Extensive library

Flavours of python:
1.Cpython--c languae
2.jython or Jpython --java
3.Iron Python-- Microsoft applications
4.Pypy---Performance wise we need to improvement then we need to go with this (PVM
==>JIT compolier is default installed)
5.RubyPython
6.AnacondaPython
----
Python versions:
Python1: 1991
python2:200
python3:2008
we are using 3.6.3==>2016

In Python does not provide old version Programms

In Python 3 long data type is not avilable

Identifiers in Python:
---------------------------
variable name,Class name, method name
x=10 x is identifier
def f1();
f1 is the function name
class Test(Exception)
Test is the identifier for class name

Rules to define Identifiers in Python;


-------------------------------------
1.Alphabet symbols(Both upper and lower case)
digits(0 to 9)
underscore(_)

123=10---- error
case sensitive programming language python:
not used reserved word like if
if=2;
throws error
max length of identifiers is infinity.
if the identifier start with _ so it is a private
if the identifier start with _ _ so it is a strongly private
if the identifier start with _ _ and ends with _ _ so it is a lanuguage special
varible (overloaded operater s we use this)

Reserved Word:
--------------
33 --reserved words

True | False | None


and | or |nor | is --operators
if | else | elif
while | for |break |continue | return |in |yield
note: switch statements not aviliable in python
try | except |finally |Raise |
import | from | as |class | def (methods and constructors declarations we used)
pass

global variable |local variable |nonlocal


anonymous functions lamda
delete a method del
with --keyword
assert is used for debugging purposes

Note:
-----
Only alphabet symbols
all lowercase except first 3

Data Types:
-----------
Represent the type of data present in variable

inbuilt datatypes:14
-----------------
int -whole values ex 10,20,300
float
complex data types
bool
str
bytes-- a group of byte values
bytearray--same
range--range of numbers
list-- a list of values
tuple-- list of values small difference like mutable immutable
set-means list of values without duplicates
frozenset-means list of values without duplicates we can't modify
dict--map/hash concept in other language
None-

Python provides an some inbuilt functions:


------------------------------------------
print()
type()
id()-- to find address of the object
everything is an object in python:
fundamental datatype:
--------------------
int ,Float,complex,bool,str
1.int:
-----
integer values we can represent the following ways:
1.Decimal form
2.Binary form
3.Octal form
4.Hexa Decmal

1.Decimal

a=7878

2.Binary(Base-2)
----------------
0 and 1
a=0b1111

3.octal:
-------
a=0o123
4.Hexa Decimal:
--------------
0-9 A-F is allowed

a=0xBeef

float:
complex: a+jb
str=='saru'

Typecasting: Type cohersion:


------------------------------------
converting one data type to other data type

int() :
------
int(10.23)=10
int(10+j20)=>error
int(true)==1
int(fale)==>0
int("10"==>10
int("10.50") ==>error

Float():
-----------
convert other to float
float(10)==>10.0
float(10+5j)==>type error
float("10")== 10.0
float("10.05")== 10.05
---------------------------
Complex:
----------
complex does not covert into int type
complex does not covert into float type

coplex we can convert bollean bool(x)

String:
--------
any type to str ==> str() function

fundamental dataypes vs immutability


-------------------------------------
*once we created we can't chnge immutability
x=10
y=10
z=10
only one object is created
if any one changed z value then that entire object is impacted

all primitive data types are immutable:

Only in the ranges:


-------------------
int==> 0-256 always exisisting objects is used
bool==> always exisisting objects is used
str==>always exisisting objects is used
float-- always a new object is creating no concept of re usability
complex-- always a new object is creating no concept of re usability

Bytes Data Types: it is used mainly in imgae and vedio processing mechanisim
----------------
Represents A group of byte numbers
x=[10,20,30,40] it is not bytes
b=bytes(x)
something like an array
1.every value in the bytes in the range of 0 to 256.
2.bytes data type is immutable
3.bytes does not support item assignment

type(b)

b[0]=10
b[-1]= 30
b[0:3]---

bytes data type and bytearray difference


bytearray --mutable --but value is in the array
bytes-- immutable

Collection Related Data Types: list,tuple,set,frozenset,dictionary


-----------------------------
List Data Type:
---------------
If we want to represent as a group of value as a single entity
where insertion order is preserved and duplicates are also allowed
hetrogenous objects allowed:
---------------------------
different types of objects
l=[]
type(l)
l.append(10)
l.append('durga')----hetrogenious object

order
duplicates
hetrogeneous
growable
values should be enclosed []
it is allowed to get values by index.
slice operator also applicable
* operator applicable any where
s=[10,"hai"]
s1=s1*2
s1=[10,"hai",10,"hai"]
it is mutable

Tuple:
------
exactly same like list only difference is tuple immutable

Tuple=(10,20,30)
tuple contains list object also
ex:
(10,20,[10,20])

Range():data type
-----------
range data type represent a sequence of values
immutable
it only applicable for int
float not applicable for range

Set:
-----
Differnce between set | List:
-------------------------------
set in not ordered/sequenced
set doesnot allow duplicates
indexing
slicing
mutable

it accepts hetrogenious

it represented {}

s={1,20,30,1,20,30}
s.add('durga')
s.remove(20)
print(s)
1,20,30

Indexing and slicing that terminology is not applicable to set becuse set order is
not internally
insertion order no
duplicates no
hetrogenious yes
index no
slicing no
growable -yes
------------------------
frozenset:
-----------
exactly same as set
immutable
syntax
s=frozenset{10,20,30,40}

we can use this no one is going to change

Dict data type:


--------------
words==>Meaninig
Key == Value pairs
mobilenum== name
emplid==name
Representation:
---------------
duplicates keys are not allowed
values may have dupplicates
{}
d={100:'durga',200:'Shiva',300:'Ravi'}
Hetrogrnious keys and values are allowed
dictionary by default mutable
add a element
d[10]='sunny'
order is not important

Constants: not have this concept but we want to give MAX_VALUE=10


-----------
final int x=10;
always fixed

Operators:
-----------
1.Arthametic Operators
2.Relational Operators or Comparision Operators
3.Logical operators
4.Bitwise Operators
5.Assignement Operators
6.Special Operators
----------------------
1.Arthematic Operator:
---------------------
+ - * / %
//--Floor Division operator
** --Exponential operator or power operator

2.Relational Operators :
-----------------------
numbers , string and boolean types it is applicable
<,<=,>,>=

based on

a='durga'
b='darga'

b is bigger

string will compare based on unique code

Chaining of Relational Operators:


---------------------------------
10<20<30<40

true
in python all
10<20<30>40
result: False

Equality operators:
------------------
==, !=

we can apply any type


10==20 false
10!=20--true
10==true-- false
false==false --true
== comprasion is only by content comparision

10=='dugra'
false
we never get errors

chaning operator is also applicable :

10==20==30==40--- false
10==3+7==5+5==2*5==6+4---true
a=10 assigning
a==10 comparision operator
10==10.0 true
smaller type is convert as bigger type
10.10=10.1 -- true

Logical Operators:
-----------------
and
or
not operators
Boolean:
----------------

and ==>if both are same then true


or if any one is true then result is true

non-boolean type:
---------------
10 or 10/0-- true

Bitwise Operators:
-----------------

&,
|
^
>>
<<
~

we can apply int type and boolean type only.

Das könnte Ihnen auch gefallen