Test Test
Test Test
&
Exercise :
Chapter S
1 .
find mean
mean ,
=
375/5 =
75
meanz =
375/5 =
75
.
2 Find Median was how 1 Was des Muse dis
Median , = 76
medianz =
76
3 Find Mode miro:
mode , = 76
mode z =
76
↑ find
53 =
variance
6
62 = 39
5 .
Find
61 =
S D
.
2 45
.
.
-
62 = 6 .
24
Chapter 9 : Stat by TM
Stat by TM
Stat by TM
Stat by TM
Stat by TM
Chapter 10
Stat by TM
Stat by TM
=
O
4
Question 8: Suppose n is given, which of the following Python snippet can calculate ∏ ln (𝑖) ? The
symbol ∏ stands for the product operator throughout mathematics. For example, ∏ 𝑥 stands for
the product 𝑥 , 𝑥 , … , 𝑥 and 𝑥 ; and ∏ i = 1 × 2 × 3 × 4 = 24.
[4 marks]
a)
𝑑=1
import math
for x in range(n):
d = d * math.log(x)
b)
d=1
import math
for x in range(2,n+1)
d = d * math.log(x)
c)
import math
for x in range(2,n):
d = d * math.log(x)
d)
d=1
import math
for x in range(2,n+1):
d = d * math.log(x)
Question 10. Which of the following statements is used to create a set in Python?
a) ( )
b) [ ]
c) { }
d) set()
[4 marks]
5
Question 11. Which of the following Python commands can be used to add a new element to a list?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
[4 marks]
Question 12. What are the two main types of functions in Python?
a) System function
b) Custom function
c) Built-in function & User defined function
d) User function
[3 marks]
Turn over
6
Question 17. David wants to create a dataframe ‘Salesdata’ based on the data from sale.csv, which is
stored in folder ‘Python’ on c: drive. Which of the following statements should he use?
a) Salesdata=pd.read_csv(“sale.csv”)
b) Salesdata=pd.read_csv(“c:/Python/sale.csv”)
c) Salesdata=pd.to_csv(“c:/Python/sale.csv”)
d) Salesdata=pd.write(“sale.csv”)
[4 marks]
Question 18. Looking at the code below, what would this line do?
newTable=pd.merge(Sales, Products, on=“ProdNo”)
a) Create a DataFrame named newTable that is the intersection of the values of the key “ProdNo”
from both Sales and Products.
b) Create a DataFrame named newTable that is the union of the values of the key “ProdNo” from both
Sales and Products.
c) Create a DataFrame named newTable that contains all the records from Sales and also those
records which satisfy a condition from Products.
d) Create a DataFrame named newTable that contains all the records from Products and also those
records which satisfy a condition from Sales.
[3 marks]
Question 19. Which of the following is the correct declaration of a function in Python?
a) def function function_name():
b) declare function function_name():
c) def function_name():
d) declare function_name():
[3 marks]
Question 20. How many times will the following loop run?
i=3
while(i>=0):
i=i-1
a) 3
b) 4
c) 2
d) 1
[4 marks]