print('Hello')
$a=b+c$ (did it using $ symbols at the end)
x = 3
%whos
print(type(x))
x = 5.07
%whos
print(type(x))
num = 234
%whos
a,b,c = 34,23.234,-23
whos
del num
%whos
c = 2+4j
print(type(c))
word = "HELLOOO"
print(type(word))
2+3
2-3
6/3
6*3
12%5
154//5
2**4
"hello"+" world"
_ #last non-assigned value
a = True
b = False
c = False
%whos
print(a and b)
print(b and c)
print(a or b)
print(b or c)
not(c)
c = (2>3)
print(type(c))
print(c)
print(round(4.7889)) #round() function
print(round(4.7889,3)) #argument for number of numbers after decimal
print(divmod(25,2)) #divmod() function . returns back qoutient and remainder
print(divmod(25,7))
print(isinstance(1,int)) #isinstance() function. checks for condition
print(isinstance(1.0,int))
print(isinstance(1.0,(int,float)))
print(pow(2,3)) #pow() function
print(pow(2,3,3)) #finds power of first two args and finds mod with 3rd argument
v = input("Enter a number")#input()
v = float(v) #changing datatype
print("The largest number will be printed.")
a = int(input("Enter a: "))
b = int(input("Enter b: "))
if a>b:
print(a)
elif a<b:
print(b)
else:
print("You entered the same numbers")
#if else ,if elif else, nested if,while,for..same as i know
def prints():
"""prints hi"""
print("Hiiii")
prints();
#fun(x,y); supplying variables
#return ___
def add(*args): #variable number of arguments
sum = 0
for i in range(len(args)):
sum+=args[i]
return sum
print(add(1,2,3))
print(add(234,234,56,35,676))
import sys
sys.path.append('/root/Desktop/')
import mymod as mod
from mymod import numeric as num
num(True)
s = 'abc'
t = "123"
print(type(s))
print(s+" and "+t)
ms = ''' hi
heyy
heyyyyyyyaaa'''
print(ms)
a = " Game of Thrones"
print(len(a))
print(a[8:17])
print(a[-7:17])
print(a[-7:])
print(a[0:17:5])
print(a[::-1])
print(a.lower())
print(a.upper())
print(a.strip())
print(a.replace("o","23"))
"abc" in "awgtfrhyjgfds"
"abc" in "abckedfrgtygfdsbac"
"sadfgFDsas" not in "edrftyhugjg"
print("I am \"THE\" hero")
print('I am "THE" hero')
print("C:\name\drive")
print(r"\C:\name\drive")
L = [1,3,4,9,"name",8]
T = (1,3,4,9,"name",8)
S = {1,3,4,4,9,"name",8}
D = {23:"twenty-three","t":23,"bcd":"are"}
print(type(L))
print(type(T))
print(type(S))
print(type(D))
print(L[3])
print(T[3])
print(3 in S)
print(D[23])
print(D["bcd"])
L[1:3]
T[1:3]
L = L+[12,"AD"]
print(L)
L.append(899)
print(L)
T2 = (1,3)
T3 = T2 + T
print(T3)
S.update({"hiii",234})
print(S)
D["neww"] = "NEWWW"
print(D)
D2 = {"hi":123}
L2 =L.copy() #same with set,dictionary
L2
L3 = L[1:5] #slicing picks a copy by default
L3
help(L.append)
L4 = [x**4 for x in range(5)]
L4
import numpy as np
a = np.array([1,2,3,4,5])
b = np.array((1,2,3,4,5))
print(a)
print(b)
print(type(a))
print(type(b))
c = np.array([234,34,2345],dtype="int")
type(c)
c.dtype
import numpy as np
a = np.array([[1,2,3],[4,5,6]])
a.ndim
a[0,2]
a[1,2]
b = np.array([[1,2,3,4],[5,6,7,8]])
b.ndim
b[0,3]
c = np.array([[[1,2,3],[4,5,6],[3,4,5]],[[1,-2,3],[4,5,6],[3,4,5]]])
c.ndim
c[1,0,1]
c.shape
print(c.size)
print(c.nbytes)
d = np.arange(100)
d
d = np.arange(0,101)
d
d = np.arange(0,11,2)
d
np.random.permutation(np.arange(10))
np.random.randint(20,300)
f = np.random.rand(100)
print(f)
import matplotlib.pyplot as plot
plot.hist(f)
c = np.random.rand(2,3)
c
c.ndim
c = np.random.rand(2,3,4,4)
c
c.ndim
d = np.arange(100).reshape(4,25)
d
a = np.arange(100)
b = a[3:10]
print(b)
b[0] = -10
a
a[::-5]
a
a+12
a.sort()
a
import numpy
b = numpy.random.rand(10000000)
%timeit sum(b)
%timeit numpy.sum(b)
def mysum(g):
s = 0
for x in g:
s+=x
return s
%timeit mysum(b)
import pandas as pd
A = pd.Series([2,3,4,5],index=['a','b','c','d'])
A.values
type(A.values)
type(A)
A.index
A['a']
A['a':'c']
grades_dict = {"A":4,"B":3,"C":2,"D":1}
grads = pd.Series(grades_dict)
grads.values
marks_dict={"A":80,"B":60,"C":40,"D":20}
marks = pd.Series(marks_dict)
marks
marks.values
marks["A"]
res = pd.DataFrame({'Marks':marks,'Grades':grads})
res
res.T
res.values
res.values[0,1]
res['Percentage(out of 90)']=100*(res['Marks']/90)
res
del res['Percentage']
res
g = res[res['Marks']>60]
g
z = pd.DataFrame([{'a':1,'b':2},{'b':3,'c':4}])
z
z.T
z.fillna(0)
z.dropna() #drops all rows which has na
z
a = pd.Series(['a','b','c'],index=[1,3,5])
a[1]
a[1:3]
a.loc[1:3]
a.iloc[1:3]
#pd.read_csv('path')
#df.head(n)
#df.drop(['Sno',..],axis=1,inaplce=True)
#df.rename(columns={'ObservationDAte':'Date'},inaplce=True)
#df.info
#df.fillna(NA)
#df.groupby('')
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,10,1000)
print(x)
plt.plot(x,np.sin(x));
plt.scatter(x[::10],np.sin(x)[::10],color='red')