Professional Documents
Culture Documents
released in 1991.
=>Python is a general purpose, dynamic, high level, interpreted programming and multi paradign
language.
=> Python language was developed by Guido van Rossum. The first version of Python was
released in 1991 from python software foundation. Python is free software and open source Official
Web site : www.python.org (http://www.python.org)
Multi Paradigm => It supports FUnctional programming, Structured or Modular Programming and
Object Oriented Programming
=>Python language is used to develop the different types of application such as stand alone
applications, web applications, scientific applications
Features of Python:
Simple to Learn and Easy to Use =>It is a programmer friendly language . => Uses an elegant
syntax, making the programs write easier.
Object Oriented Programming Language: =>Python supports object oriented features classes
,objects, inheritance etc..
Platform Independent =>We can develop any application using Python on one platform and we
can run this python code on any platform
#Snake case (or snake_case) is the practice of writing compound words or phrases
#in which the elements are separated with one underscore character
#As Python has no concept of private variables, leading underscores are used
#to indicate variables that must not be accessed from outside the class
#True, False and None are capitalized keywords while the other keywords are in lower case.
result = a+b*c
#Operators with the same precedence are evaluated in "Left to Right" manner
#Note that the precedence order of Division and Multiplication is the same.
#https://www.sanfoundry.com/python-questions-answers-precedence-associativity-2/
(https://www.sanfoundry.com/python-questions-answers-precedence-associativity-2/)
#https://www.sanfoundry.com/python-questions-answers-precedence-associativity-1/
(https://www.sanfoundry.com/python-questions-answers-precedence-associativity-1/)
Out[8]: 43
In [9]: name
Out[9]: 'Lakshmi'
In [10]: city
Out[10]: 'Hyderation'
In [ ]: +
-
*
/
%
**
In [12]: 2/5
Out[12]: 0.4
In [2]: 2**2**4
#Left to right Associativity
Out[2]: 65536
In [4]: 25%3
Out[4]: 1
#Github
#https://www.analyticsvidhya.com/ (https://www.analyticsvidhya.com/)
#StatQuest
#3Blue1Brown
https://www.youtube.com/watch?v=jc2IthslyzM&vl=en (https://www.youtube.com/watch?
v=jc2IthslyzM&vl=en)
Packages
#numpy - Numerical Opearations
"""To get a little overview here are a few popular plotting libraries: Matplotlib: low level, provides
lots of freedom Pandas Visualization: easy to use interface, built on Matplotlib Seaborn: high-level
interface, great default styles ggplot: based on R’s ggplot2, uses Grammar of Graphics Plotly: can
create interactive plots"""
In [6]: # defining a variable : In Python there is no need to mention the data type
10 3.146 Python
1 1 1
1 2.5 Python
In [13]: # Slicing
# String operations
Hello World!
H
llo
llo World!
He
Hello World!
Hello World!Hello World!
Hello World!Hello Bvrit
100 in l1
4 in l1
Out[5]: True
1
2
3
4
5
6
7
8
In [16]: trainees=[]
trainees.append("Pooja")
trainees.append("Mohammed")
trainees.append("Rajani")
trainees[2]="Guru"
trainees.pop()
trainees.reverse()
trainees
#transation = {Purchaseorder:"ZZ12345",Name:"Rajani",Account:"12321423423",Amount
tel = {'jack': 4098, 'sape': 4139}
tel['guido'] = 4127
#print(tel['jack'])
del tel['sape']
print(tel)
tel['irv'] = 4127
print(tel)
print(tel.keys())
print(sorted(tel.keys()))
print(sorted(tel.values()))
print('guido' in tel)
print('jack' not in tel)
print("sape" not in tel)
if i%2 == 0:
print("Square of ",i," is :",i*i)
else:
print(i,"is an odd number")
print("loop done")
Square of 0 is : 0
1 is an odd number
Square of 2 is : 4
3 is an odd number
Square of 4 is : 16
5 is an odd number
Square of 6 is : 36
7 is an odd number
Square of 8 is : 64
9 is an odd number
loop done
In [27]: #Built-in Functions¶
print("Sum of array: ",sum([1,2,3,4]))
print("Length of array: ",len([1,2,3,4]))
print("Absolute value: ",abs(-1234))
print("Round value: ",round(1.62234))
Sum of array: 10
Length of array: 4
Absolute value: 1234
Round value: 2
Log value: 2.302585092994046
In [30]: #Functions
def area(l,w):
a=l*w #Function body
return a
#arr = [100, 50, 400, 300, 200] arr=[15, 14, 12, 13, 120, 15, 16, 14, 12, 14, 11, 16, 14, 12, 13]
x=np.mean(arr) xtice that our data has certain erroneous values in it. Which of the following
normalization techniques would you use to normalize data with such erroneous values?
[15, 14, 12, 13, 120, 15, 16, 14, 12, 14, 11, 16, 14, 12, 13]
Out[2]: 20.733333333333334
In [3]: y=np.std(arr)
y
Out[3]: 26.56932232648942
In [4]: # Z Score
for i in range(len(arr)):
print((arr[i]-x)/y)
-0.21578771422473364
-0.25342510624067555
-0.32869989027255936
-0.29106249825661745
3.7361384474491666
-0.21578771422473364
-0.17815032220879173
-0.25342510624067555
-0.32869989027255936
-0.25342510624067555
-0.36633728228850126
-0.17815032220879173
-0.25342510624067555
-0.32869989027255936
-0.29106249825661745
In [5]: #min-Max
for i in range(len(arr)):
print((arr[i]-min(arr))/(max(arr)-min(arr)))
0.03669724770642202
0.027522935779816515
0.009174311926605505
0.01834862385321101
1.0
0.03669724770642202
0.045871559633027525
0.027522935779816515
0.009174311926605505
0.027522935779816515
0.0
0.045871559633027525
0.027522935779816515
0.009174311926605505
0.01834862385321101
In [7]: import numpy as np
import matplotlib.pyplot as plt
#y = a + bx + cx2
a=10
b=20
c=30
plotx=[]
ploty=[]
for x in range(-100,100):
y=a+b*x+c*x*x
plotx.append(x)
ploty.append(y)
plt.plot(plotx,ploty,"r.")
plt.show()
In [8]: #From the below graphs, select the one that satisfies the equation y=σ(0.1∗x):
import numpy as np
import matplotlib.pyplot as plt
x=[]
y=[]
for i in range(-100,100):
a = 1/(1+np.exp(-0.1*i))
#a = np.std(0.1*i)
x.append(i)
y.append(a)
plt.plot(x, y, 'r--')
plt.show()
Out[9]: 190.0
In [10]: import numpy as np
arr = [ 100, 50, 400, 300, 100]
y=np.std(arr)
y
Out[10]: 135.64659966250537
In [11]: # Z Score
for i in range(len(arr)):
print((arr[i]-x)/y)
-0.6634888026970371
-1.03209369308428
1.5481405396264198
0.8109307588519342
-0.6634888026970371
In [12]: #min-Max
arr = [ 100, 50, 400, 300, 100]
for i in range(len(arr)):
print((arr[i]-min(arr))/(max(arr)-min(arr)))
0.14285714285714285
0.0
1.0
0.7142857142857143
0.14285714285714285
In [ ]:
In [ ]:
In [ ]:
In [ ]: