Skip to content

Instantly share code, notes, and snippets.

View Chap8Q2c.py
import pandas as pd
import matplotlib.pyplot as plt
df= pd.read_csv("/est.csv")
print(df)
df.plot.bar()
View Chap8Q1b.py
import pandas as pd
import matplotlib.pyplot as plt
labels=['North', 'South', 'East','West','Central']
sizes =[140, 160,140,180,110]
colors=['gold','yellowgreen','lightcoral','lightskyblue','pink']
explode=(0.1,0,0,0,0)
plt.pie(sizes,explode=explode,
labels=labels,colors=colors,shadow=True, startangle=140, autopct='%1.1f%%')
View Chap8Q1c.py
plt.plot([140,130,130,190,160,200,150,170,190,170,150,120], label='North')
plt.plot([160,200,130,200,200,170,110,160,130,140,170,200], label= 'South')
plt.plot([140,180,150,170,190,140,170,180,190,150,140,170], label='East')
plt.plot([180,150,200,120,180,140,110,130,150,190,110,140], label='West')
plt.plot([110,160,130,110,120,170,130,200,150,160,170,130], label='Central')
plt.title("Rainfall from Jan to Dec")
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.legend()
View Chap1Q1.py
x=int(input("Enter any number:"))
if x<0:
print('Negative')
elif x==0:
print('Zero')
else:
print('Positive')
View Chap1Q2.py
def even_odd(x):
if x%2==0:
return True
else:
return False
a=int(input("Enter any number:"))
even_odd(a)
View Chap1Q3.py
days=365
hours=24
minutes=60
seconds=60
print("Number of seconds in a year are:",days*hours*minutes*seconds)
View Chap1Q4.py
x,y =map(int,input("Enter Two numbers:").split())
#map() is used to make the variable an int
if(x%y)==0:
print('First number is divisible by second')
else:
print('First number is not divisible by second')
View Chap1Q5.py
def numberedDay(firstDay, dayNumber):
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
firstIndex = days.index(firstDay)
endIndex = (firstIndex + int(dayNumber) - 1) % 7
return days[endIndex]
year = input("Year: ")
firstDay = input("First day of the year (e.g. 'Monday'): ")
dayNumber = input("Day number: ")
View Chap1Q6.py
def feet_to_inches(x):
return x*12
def feet():
x = int(input('Enter feet : '))
return x
def disp_inches(x):
print('Number of inches :', x)
View Chap1Q7.py
n = int(input("Enter an Integer: "))
x = 0
if n > 0:
for i in range(n, 2*n+1):
x += i
else:
for i in range(2*n, n+1): # for negative n, we need to reverse start & end of range
x += i
print(x)