You are on page 1of 4

Python for Analytics

Maximum Marks: 30
Instructions
 Write the Python code. Python code should be supported with comments.
 Answers should be concise and avoid wordy sentences.
 Each descriptive question has 5 marks. Answer only 4 descriptive questions.
 Each multi choice questions has 2 marks

QUESTION – 1 (5 Marks)
A price of a mobile is $200, on which retailer get a 15% discount from a mobile
manufacturer. Shipping charges are $50 for the 10 mobiles shipped together. The discount
on shipping is as below.
No discount for first 30 mobiles.
25% discount on $50 for shipping of next 100 mobiles.
50% discount on $50 for shipping after 100 mobiles.
What is the total wholesale cost for 150 mobiles? Solve this problem and write python code.

QUESTION – 2 (5 Marks)
A customer support office receives many emails in a week. An executive can reply maximum
of fifty emails in a day. An executive works five days a week. Write Python code to calculate
how many emails an executive can answers and pending at the end of the week. Also,
calculate how many more executives are required to answer pending emails.

Input is the number of emails received on each day in a week. E.g. [52, 66, 77, 61, 87, 71, 23]
Solve this problem and write python code.

QUESTION – 3 (5 Marks)
You have invested Rs. 10000 and Rs. 5000 in small cap and large cap fund. The growth of the
investment at the end of each year is give in the below lists. At the end of 10 years, which of
the funds performed better? Write the Python code to find your answer.

small_cap = [11000,12000,13500,15000,17000,18500,20500,22000,26000,30000]
large_cap = [5700,6700,8900,9200,11500,13500,15000,17500,20000,22500]

QUESTION – 4 (5 Marks)
Data for a sample of 36 members of the Baseball Hall of Fame in Cooperstown, New York,
are shown here. Each observation indicates the primary position played by the Hall of
Famers: pitcher (P), catcher (H), 1st base (1), 2nd base (2), 3rd base (3), shortstop (S), left
field (L), center field (C), and right field (R).
[L, P, C, H, 2, P, R, 1, S, S, 1, L, P, P, P, R, C, S, L, R, P, C, C, P, 2, 3, P, H, L, P, 1, C, P, P, P, S]
Summarize the data to find below answers. Write python code.
[A] What position provides the most Hall of Famers?
[B] What position provides the fewest Hall of Famers?

QUESTION – 5 (5 Marks)
Walt Disney Company bought Pixar Animation Studios, Inc., in a deal worth $7.4 billion. The
animated movies produced by Disney and Pixar during the previous 10 years are listed
below. The box office revenues are in millions of dollars. Compute the total revenue, the
mean, and the median. Using this data compare the box office success of the movies
produced by both companies. Discuss.

Pixar = [362, 363, 485, 525, 865, 631]


Disney = [346, 325, 253, 304, 448, 354, 169, 273, 110, 136, 250, 104, 249]

MCQ QUESTIONS (Each question has 2 marks.)


QUESTION-1

What is output of following code?


def fact(n):
a=1
for count in range(2, n+1):
a = a * count
return(a)
fact(5)

[A] 5
[B] 100
[C] 120
[D] 90

QUESTION-2

What is output of following code?


airports = pd.read_csv(“data1.csv", column = [‘id’, ‘airport_ident ‘,‘type’,’ frequency_mhz’])
airports[~airports.type.isin(['heliport', 'balloonport'])]

[A] Get the records of DataFrame airports where type column values are either 'heliport'or
'balloonport'
[B] Get the records of DataFrame airports where type column values are neither 'heliport'
nor 'balloonport'
[C] Get the records of DataFrame airports where type column values are either 'heliport'
and 'balloonport'
[D] None answer is correct.

QUESTION -3

What is output of following code?


df[['brand','flavor']].loc[df['flavor'] == 'Original']

[A] It will return the rows of dataframe df of column 'brand' and 'flavor' with a value Original
in column 'flavor'.
[B] It will return the rows of dataframe df for column 'brand' and 'flavor'.
[C] It will return the rows of dataframe df with a value Original in column ‘flavor’
[D] None answer is correct.

QUESTION -4

What is output of following code?


data = { 'name': ['John', 'Michael', 'Tina', 'Jake', 'Jashon','Jane'],
'age': [42, 52, 36, 24, 73,25],
'preTestScore': [4, 24, 31, 2, 3, 22],
'postTestScore': [25, 94, 57, 62, 70, 34] }

df = pd.DataFrame(data, columns = ['name', 'age', 'preTestScore', 'postTestScore'])


df.shape(), df['preTestScore'].var(), df['postTestScore'].mean()

[A] It will print (no. of rows of df,no. of columns of df), standard deviation and mean of
'preTestScore' column.
[B] It will print size of df, variance of 'preTestScore' column and mean of 'postTestScore'
column.
[C] It will print (no. of rows of df,no. of columns of df), variance of 'preTestScore' column
and mean of 'postTestScore' column.
[D] It will print shape of df, standard deviation of 'preTestScore' column and mean of
'postTestScore' column.
QUESTION -5

What is output of following code?


df['preTestScore'].describe()

[A] It will print count, mean, standard deviation min, Q1,Q2,Q3,max for 'preTestScore'
column of dataframe df.
[B] It will print five number summary of data frame df.
[C] It will print count,min,max, mean, standard deviation, Q1,Q2,Q3, for 'postTestScore'
column of dataframe df.
[D] It will print count,min,max, mean, standard deviation, Q1,Q2,Q3, for 'preTestScore'
column of dataframe df.

You might also like