Python Notebook
Python Notebook
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
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
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
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-
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'
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
String:
--------
any type to str ==> str() function
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]---
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}
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
true
in python all
10<20<30>40
result: False
Equality operators:
------------------
==, !=
10=='dugra'
false
we never get errors
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:
----------------
non-boolean type:
---------------
10 or 10/0-- true
Bitwise Operators:
-----------------
&,
|
^
>>
<<
~