You are on page 1of 8

AB Group 10 Assignment

Sanket Andhare MBA21191

Q1.

def Eval_Quadratic_Equa(m,n,o,p):

return(m*(p**2)+n*p+o)

m=int(input("Enter the first number: "))

n=int(input("Enter the second number: "))

o=int(input("Enter the third number: "))

p=int(input("Enter the fourth number: "))

Quad= Eval_Quadratic_Equa(m,n,o,p)

print("The value of Quadratic is :",Quad)

Q2.

def expo_cal(b,e):

if e==0:

return 1

return(b*expo_cal(b,e-1))

x=int(input("Enter the value of base: "))

y=int(input("Enter the value of exponent: "))

val = expo_cal(x,y)
print("The value of power is: ", val)

Q3.

def GCD_num(x,y):

if(y==0):

return x

return GCD_num(y,x%y)

a=int(input("Enter the first number: "))

b=int(input("Enter the second number: "))

Divisor=GCD_num(a,b)

print("The greatest common divisor is:",Divisor)

Q4.

def reverse_num(x):

rev_num=0

while(x>0):

rem=x%10

rev_num=(rev_num*10)+rem

x=x//10

return rev_num

a=int(input("Enter a number to reverse: "))

rev=reverse_num(a)

print("The reversed number is: ",rev)

Q5.
def sum_dig(x):

if(x==0):

return 0

return(x%10 + sum_dig(int(x//10)))

a=int(input("Enter the numbner for sum of it's digits: "))

sum=sum_dig(a)

print("The sum of digits is: ",sum)

Q6.

class circle():

def __init__(self,radius):

self.radius=radius

def get_radius(self):

return self.radius

def area(self):

return 3.14*self.radius**2

r=int(input("Enter radius of circle: "))

obj=circle(r)

print("The radius of the circle is:",obj.get_radius())

print("Area of circle:",round(obj.area(),2))

Q7.

import pandas

Data={'Fname':["Tom","Krish","Nick","Juli"],
'Lname':["Reacher","Pete","Wilson","Williams"],

'Age':[25,30,26,22]}

df=pandas.DataFrame(Data)

df

Q8.

import pandas as pd

Data={'ID':["MBA21001","MBA21002","MBA21003","MBA21004","MBA21005","MBA21006"],

'Name':["Rohit","Meenal","Sneha","Mrigank","Naresh","Deepika"],

'Gender':["Male","Female","Female","Male","Male","Female"],

'Age':[24,25,22,23,25,23],

'Family_income':[120000,98000,112000,85000,92000,106000]}

df=pd.DataFrame(Data)

df

print("The mean age of the group is:",round(df["Age"].mean(),2))

print("The median age of the group is:",round(df["Age"].median(),2))

print("The standard deviation of age of the group is:",round(df["Age"].std(),2))

print("The mean income of the group is:",round(df["Family_income"].mean(),2))

print("The median income of the group is:",round(df["Family_income"].median(),2))


print("The standard deviation of income of the group is:",round(df["Family_income"].std(),2))

Q9.

import pandas as pd

import matplotlib.pyplot as plt

Data={'Month':["January","February","March","April","May","June","July",

"August","September","October","November","December"],

'Sales(million $)':[50,30,20,15,17,55,40,25,20,60,35,40]}

df=pd.DataFrame(Data)

df.plot()

plt.title("Line Chart")

plt.xlabel("Month")

plt.ylabel("Sales Million $")

df.plot(kind="bar")

plt.title("Bar Chart")

plt.xlabel("Month")

plt.ylabel("Sales Million $")

Q10.

import pandas as pd

import matplotlib.pyplot as plt

Data={'Industry':["IT","Sales & Marketing","Finance & Banking","Manufactuting","Others"],

'Placement':[55,88,39,24,63]}
df=pd.DataFrame(Data)

df.groupby(['Industry']).sum().plot(kind="pie",y="Placement",autopct='%1.0f%%')

Q11.

class Demo():

def _init_(self):

self.x=""

def Get_String(self):

self.x=input("Enter the string to be converted:")

def Print_String(self):

print("The Upper case string is:",self.x.upper())

str1 = Demo()

str1.Get_String()

str1.Print_String()

Q12.

class circle():

def __init__(self,radius):

self.radius=radius

def get_radius(self):

return self.radius

def area(self):

return 3.14*self.radius**2

def peri(self):

return 2*3.14*self.radius
r=int(input("Enter radius of circle: "))

obj=circle(r)

print("The radius of the circle is:",obj.get_radius())

print("Area of circle:",round(obj.area(),2))

print("Perimeter of circle:",round(obj.peri(),2))

Q13.

class Point():

def _init_(self,x,y):

self.x=""

self.y=""

def Display(self):

self.x=int(input("Enter the x coordinate:"))

self.y=int(input("Enter the y coordinate:"))

print("The x coordinate is:",self.x)

print("The y coordinate is:",self.y)

def Translate(self):

self.a=int(input("Enter the amount to move x by:"))

self.b=int(input("Enter the amount to move y by:"))

self.x=self.x + self.a

self.y=self.y + self.b

print("The new x coordinate is:",self.x)

print("The new y coordinate is:",self.y)

p=Point()

p.Display()
p.Translate()

You might also like