Hello world¶
InĀ [1]:
print("hello world")
hello world
InĀ [6]:
name = input("Enter your name: ")
message = "Hello " + name
print(message)
Hello Sonam
InĀ [7]:
x = 4
x + x
Out[7]:
8
InĀ [Ā ]:
age = 45
height =176.5
name = "sonam"
data_science_student = True
Arthematic operators¶
InĀ [Ā ]:
+(add) -(minus) *(times) / // %(remainder) **
Comparison operators¶
==(LHS = RHS) !=(is not equal to) > < >= <= asking question equalto etc.
Logical Operators¶
and or not
InĀ [16]:
x = 6
y = 7
print(x == y)
False
InĀ [18]:
x = 5
y = 4
print(x > y and y>x)
print(x > y or y>x)
False True
Condition Statements syntax¶
if elif else
InĀ [19]:
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
Adult
Numpy¶
InĀ [2]:
import numpy as np
x = np. array([1,2,3])
a = [1,2,3]
b = [2,2,2]
print(a*b)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[2], line 5 3 a = [1,2,3] 4 b = [2,2,2] ----> 5 print(a*b) TypeError: can't multiply sequence by non-int of type 'list'
InĀ [11]:
import numpy as np
x =np.array([1,2,3])
a =np.array([1,2,3])
b =np.array([2,2,2])
print(a*b)
[2 4 6]
InĀ [12]:
print(x.dtype)
int64
InĀ [13]:
x = np.array([1.5,2,3, "Sonam"])
print (x)
print(x.dtype)
['1.5' '2' '3' 'Sonam'] <U32
InĀ [18]:
y=np.array([
[2,-3,1],
[2,0,-2],
[1,4,5]])
print(y)
print(y.shape)
[[ 2 -3 1] [ 2 0 -2] [ 1 4 5]] (3, 3)
InĀ [1]:
coeff1 = np.polyfit(x, y, 1)
coeff2 = np.polyfit(x, y, 2)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[1], line 1 ----> 1 coeff1 = np.polyfit(x, y, 1) 2 coeff2 = np.polyfit(x, y, 2) NameError: name 'np' is not defined
InĀ [2]:
years = np.array([2017, 2018, 2019, 2020, 2021, 2022])
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[2], line 1 ----> 1 years = np.array([2017, 2018, 2019, 2020, 2021, 2022]) NameError: name 'np' is not defined
InĀ [3]:
import numpy as np
InĀ [4]:
years = np.array([2017, 2018, 2019, 2020, 2021, 2022])
Youtube Video Tutorial & Other links¶
Begining Data Visualization¶

InĀ [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
%matplotlib inline
InĀ [2]:
randomNumber = np.random.rand(10)
InĀ [4]:
print(randomNumber)
[0.6029832 0.16269755 0.97031104 0.76146003 0.38439745 0.07017537 0.42524745 0.729962 0.07035572 0.89061723]
InĀ [8]:
style.use('ggplot')
plt.plot(randomNumber,'g',label='line one', linewidth=2)
plt.xlabel('Range')
plt.tlabel('Numbers')
plt.title('First Plot')
plt.legend()
plt.show()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[8], line 1 ----> 1 style.use('ggplot') 2 plt.plot(randomNumber,'g',label='line one', linewidth=2) 3 plt.xlabel('Range') AttributeError: 'str' object has no attribute 'use'
InĀ [9]:
style=('ggplot')
plt.plot(randomNumber,'g',label='line one', linewidth=2)
plt.xlabel('Range')
plt.ylabel('Numbers')
plt.title('First Plot')
plt.legend()
plt.show()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[9], line 4 2 plt.plot(randomNumber,'g',label='line one', linewidth=2) 3 plt.xlabel('Range') ----> 4 plt.tlabel('Numbers') 5 plt.title('First Plot') 6 plt.legend() AttributeError: module 'matplotlib.pyplot' has no attribute 'tlabel'
InĀ [Ā ]: