0% found this document useful (0 votes)
76 views28 pages

This Book Should Be Used ONLY As A Guideline To Practice What Is Taught in Class. Exam Questions Will Tend To Change, But Have A Similar Pattern

This book should be used ONLY as a guideline to practice what is taught in class. Exam questions will tend to change, but have a similar pattern. It provides a summary of key subjects and materials for the 1st year, 2nd semester including Information Technology, Medical Physics, Organic Chemistry, and Chinese II. The book was compiled by several students and edited by one to ensure all students have equal access to relevant course materials and high yield points of exam questions.

Uploaded by

Bridget Hope Liu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views28 pages

This Book Should Be Used ONLY As A Guideline To Practice What Is Taught in Class. Exam Questions Will Tend To Change, But Have A Similar Pattern

This book should be used ONLY as a guideline to practice what is taught in class. Exam questions will tend to change, but have a similar pattern. It provides a summary of key subjects and materials for the 1st year, 2nd semester including Information Technology, Medical Physics, Organic Chemistry, and Chinese II. The book was compiled by several students and edited by one to ensure all students have equal access to relevant course materials and high yield points of exam questions.

Uploaded by

Bridget Hope Liu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

This book should be used ONLY as a guideline to practice what is taught in class.

Exam questions will tend to change, but have a similar pattern.

1st year, 2nd semester

Subjects in this book:


1. Information Technology.............................................................................................................Pg3
2. Medical Phsyics.........................................................................................................................Pg29
3. Organic Chemistry.....................................................................................................................Pg43
4. Chinese II...................................................................................................................................Pg63

Subject Code Last Paper Pattern Credits


Information Technology IP 37 MCQ , 15 SAQ , 2 LAQ 3
Medical Phsyics MP 50 MCQ 5
Organic Chemistry ORC 9 MCQ , 15 Naming , 24 SAQ 5
Chinese II CHN 35 MCQ , 10 SAQ 14

Page 1 of 67
NMUISA Academic Affairs 2021/2022
Credits

Auxilium was created by the NMUISA Academics Affairs to ensure that all students have equal access to
relevant course materials, including high yield points of the exam.
This idea was proposed by President Shan Hemachandra, taken up by Director Aruthnie Jayamaha and the
Academics Affairs to create the book series.

The first edition cover was designed by Akshaya Iyer.

The second edition cover was designed by Shan Hemachandra.

This book (First Year Second Semester) was compiled by the collective efforts of
Nishant Singh Bhati , Rakshita Bharti , Sanjeevini Gogoi and Nisha Kaur .

This book was edited by Nisha Kaur

Page 2 of 67
NMUISA Academic Affairs 2021/2022
Information Technology
MCQ

1. The output of the expression “True 9. A variable is a fixed value such as


and (1>2)” is False. number , letter , and string

a. True a. True
b. False b. False

2. "+" means "concatenate" if 10. The break statements ends the current
something is a number loop and jumps to the statement
⑧ a. True immediately following the loop
b. False a. True
b. False
3. Strings can be enclosed in single
quotes (‘...’) or double quotes (“...”) 11. Python Variable Name is case
with the same result. sensitive
Ia. True a. True
b. False b. False
4. Strings can be indexed (subscripted),
with the first character having index 1 12. The output of the expression
a. True “12//5+3*((7%3)-4)” is -4.
Ib. False a. True
b. False
5. “=” is a Comparison Operator, which
means "equal to". 13. The following codes will draw a

a. True black line by matplotlib.
b. False import matplotlib.pyplot as plt
plt.plot ([1,2,3,4])
6. The following line of code will set a. True
text labels of x axis. b. False
xticks([0, 1, 2]) , [‘January’ ,
'February’ , 'March'] , (rotation=20) 14. In two-way Decision, we must choose
a. True one or the other path but not both
b. False a. True
b. False
7. The input() function returns a integer
a. True 15. Matplotlib.pyplot.pie() function will
b. False make a pie chart of array x. The
fractional area of each wedge is given
8. Indices of strings may also be by x/sum(x)
negative numbers , to start counting a. True
from the right b. False
a. True
b. False

Page 3 of 67
NMUISA Academic Affairs 2021/2022
16. Lists might contain items of different d. 10~99
types, but usually the items all have
the same type
a. True 22. Write what it prints out after the
b. False below code being executed.
17. The string should be enclosed in lst_a=[1,2,3,4,5]
double quotes if the string contains a While len(lst_a)>0:
single quote and no double quotes Print (lst_a.pop(), end = ‘,’
a. True
b. False a. 5,4,3,2,1,
b. 5,
18. Each pyplot function makes some c. 5
change to a figure; d. 5,4,3,2,1
Eg. creates a figure , creates a plotting
area in a figure, plots some lines in a 9.25
23. range(2,8,3) include _________?
plotting area, decorates the plot with a. 2 8 3 Code: print (list range (2,8,311)

labels, etc b. 2 3 5
a. True c. 2 5 8
b. False d. 2 5

19. Unlike strings , which are immutable, 24. my_str = ‘Hello’


lists ate a mutable type, i.e it is a my_str = ‘JAY’ + my str[1:]
possible to change their content. What is the value of my_str?
a. True
b. False a. JAYello
b. JAYllo
20. What does it print out after the below c. JAYe
code of being executed ? d. JAYHello

The_sum =0 25. What does it print out after the below


For number in [1,2,3,4,5,6]: code being executed?
If number%3: Def func(x):
The_sum = the_sum + number If (x==0 or x==1):
print(the_sum) return 3
p=x-func(x-2)
a. 9 return p
b. 5
c. 12 print(func(3))
d. 3 a. 0
linides
b. -1
21. What’s range of the random number c. 3
created by the expression d. 7
(int(random.random()*90+10))
a. 0~90
b. 10~90
c. 0~99

Page 4 of 67
NMUISA Academic Affairs 2021/2022
26. _______ can’t be a variable name in 30. What does it print out after the below
python? code being executed?

a. _bmi a=1
b. 5paint b=3
c. Type_2 If a>2:
d. Height print(“b is” , b)
If b>2:
27. What does it print out after the below c=a+b
code being executed? Print (“c is” , c)
else:
a=1 Print (“a is ” , a)
b=3
If a>2: a. c is 4
If b>2: b. a is 1
c=a+b c. nothing
Print (“c is” , c) d. b is 3
else:
Print (“a is ” , a) 31. Which of the following works without
any error ?
a. c is 4
b. Nothing a. var ‘123’* 5
c. a is 1 b. var ‘xyz123’* 10.5
d. b is 3 c. var ‘xyz123’* ‘5’
d. var ‘123’* 5.0

28. What does it print out after the below 32. What does it print out after the below
code being executed ? code being executed?
a. 5
b. 7 x=3
c. 9 y=2
d. 2 While x<10:
If y%x = =2:
29. Whose value does not equal to 4.0 print (y)
a. 16**1/2 x=x+y
b. pow(1,0.5) y=y+1
c. pow(16,1/2)
d. 16**0.5 a. 2
b. 1
c. 3
d. 4

Page 5 of 67
NMUISA Academic Affairs 2021/2022
33. What’s the results of the following 37. Which line of code can realize the
code? following requirements.
Print (‘aaZ’ < ‘aaz’)
There is a test, txt file, open this file
a. Yes in append mode, and use variable f to
b. 1 receive the return value of the file
c. True
d. Y a. f= open(“test.txt”, “a”)
b. f= open(“test.txt”, “r”)
34. The function of the following codes c. f= open(“test.txt”, “w”)
is : open the test, TXT file, use the d. f= open(“test.txt”, “r+”)
variable f to receive the return value
and close the file.
Please fill in the line (1) top complete
the above function
f = open(“test.txt” , “r”)
content = f.read()
( line(1) )

a. content.shutoff()
b. f.close()
c. content()
d. f.shutoff()

35. Giving lst = list(range(10)), a=[1,2,3] ,


the value of the expression “a in lst”
is _____.

a. 1
b. True
c. 0
d. False

36. What does the following Python


Programme print out?
user_str = “aabbcc”
sub_str2 = user_str[1:4]
print(sub_str2) #line 1

a. Aabb
b. Abc
c. Aabbcc
d. abb

Page 6 of 67
NMUISA Academic Affairs 2021/2022
SAQ
42. Given : s = ‘Welcome to China!’ .
38. my_str = ‘Python Rules!’ What is the What is the value of s[ : 6 : 2 ]?
value of (Quotation marks not included)
my_str.upper()find(‘T)?

43. The function str.strip([chars]) will


39. _______ is printed by the following return a copy of the string with the
codes in the first line. leading and trailing characters
_______ is printed by the following removed. The chars argument is a
codes in the second line. string specifying the set of characters
to be removed. For example, the
i=1 return value of
j =0 ‘www.example.com’.strip(‘cmowz.’)
is ‘example’ .
while i<10: So, what is the value of
i+=1 “www.test.edu.cn”.strip(“w.educn”)
j*=i
44. The output of the expression
print (i) “round(4.6)” is _____
print (j)
45. Given
40. The output of the expression “2**3”
is ________ >>> a = [‘a’, ‘b’, ‘c’]
>>> n = [1,2,3]
>>> x = [a, n]
41. Please fill in the blanks in (1) and (2) What is the value of len(x) ?
of the following codes to draw the
figure like this.

X = [1,2,3,4,5,6]
Y = [82, 84, 89, 76, 94, 74]
fig = plt.figure()
plt.( 1 )(X,Y,0.4,color=”green”)
plt.xlabel(“Classes”)
plt.ylabel(“ 2 ”)
plt.title (“The average score of six
classes”)
plt.show()

1=
2=
Page 7 of 67
NMUISA Academic Affairs 2021/2022
46. Please fill in the ( 1 ) to get the figure 49. _______ is printed by the following
of BMI of every person : codes in the first line.
_______ is printed by the following
Import numpy as np codes in the second line.
Import matplotlib.pyplot as plt _______ is printed by the following
X1 = np.arange(4) codes in the third line
height = np.array([1.65, 1.6, 1.7, 1.76])
weight= np.array([62, 50, 65, 65]) x=5
bmi = weight/(height**2) If x == 5 :
plt.xticks(x1, (‘Ankit’ , ‘Hans’ , ‘Joe’ , print(‘Equals 5’)
‘Flaco’)) If x > 4 :
plt.bar( 1 , color = “blue”) print(‘Greater than 4’)
If x > 5:
print(‘Greater than 5’)
If x !=6 :
print(‘Not equal 6’)

50. The output of the expression “4>=4”


is _____.

51. _______ is printed by the following


codes in the first line.
47. Please fill in the blank ( 1 ) in the
_______ is printed by the following
following codes to print the first 5
codes in the second line.
lines of the file without an empty line
between two lines of data.
Def greet(lang):
If lang ==’es’:
f= open(“grade.txt”)
print(‘Hola’)
gradeList =[]
Elif lang == ‘fr’:
For i in range (0,5):
print (‘Bonjour’)
x=f.readline()( 1 )
Else:
print (x)
print(‘Hello’)
gradeList.append(x)
print(gradeList)
greet(‘Ch’)
f.close()
greet(‘fr’)

48. What is the value of the following


52. Given squares = [1, 4, 9, 16,25] ,
codes?
what is the value of squares [-1] ?
print(len(‘1,2,3’.split(‘,’)))

Page 8 of 67
NMUISA Academic Affairs 2021/2022
LAQ

53. Write the whole paragraphs of program to sum up all the numbers between the input lowerbound and
upperbound (including both bounds) according to the provided code .
For example :
Pls input the lowerbound : 5
Pls input the upperbound : 25

The program is :

Def summing (a,b) :


__________________________________________________________________
__________________________________________________________________
return______________________________________________________________

lb=input(“pls input the lowerbound:”)


ub=_________________________
s=summing(lb,ub)
print(s)

54. Given the values of height, weight, and name of four guys are defined as follows.

Height = [1.6, 1.65, 1.7, 1.76]


Weight = [50, 62, 65, 65]
Names = [‘David’ , ‘Tom’ , ‘Steph’ , ‘Sarah’]
Please calculate the BMI of each person and draw a figure like the following.
Note : Please check all the properties of the figure.

Page 9 of 67
NMUISA Academic Affairs 2021/2022
Chaoxing Questions 8 ) Predict the outcomes of the following
expressions, given a = 5, b = 4, and c = 4.
1)Predict the output: (2**2)**3 b**c

Ans-64 Ans-256

2)my_int = 5
my_int = my_int + 3 9)Assignment:
print(my_int) my_var1 = 7.0
If you execute the three lines of code, what my_var2 = 5
will be printed? print(my_var1 % my_var2)
If you execute the three lines of code, what
Ans-8 will be printed?

3 ) Predict the outcomes of the following Ans-2.0


expressions, given a = 5, b = 4, and c = 3.
a%b
10)Predict the output: 2**2**3
Ans-1
Ans-256
4)Given the following variable assignments:
var_1 = 2.0
var_2 = "apple" 11)write what it prints out after the below
var_3 = 'orange' code being excuted.
var_4 = 2
What is the output of the following print x=6
statements? if x == 5 :
print(var_2*var_4) print('Equals 5')

Ans- appleapple A.Equals 5


B.Less than 5
5)Try to predict what will be printed by the C.Greater than 5
following: D.nothing

x=4 Ans- D
y=5
print (x//y)

Ans-0

6 ) Predict the outcomes of the following


expressions, given a = 5, b = 4, and c = 2.
a//c

Ans-2

7)Given the expression: 30 - 3 ** 2 + 8 // 3


** 2 * 10
What is the output of the expression?

Ans-21

Page 10 of 67
NMUISA Academic Affairs 2021/2022
12)write what it prints out after the below B.Medium
code being excuted.
C.Large
x=6
D.Nothing
if x > 1 :
print('More than 1')
Ans-B
if x > 10 :
print('more than 10')
15)write what it prints out after the below
A.More than 1 code being excuted.

B.More than 10 x=20


if x < 2 :
C.More than 1 print('Small')
More than 10 elif x < 10 :
print('Medium')
D.Nothing else :
print('Large')
Ans-A
A.Small
13)write what it prints out after the below
B.Medium
code being excuted.
x=4
C.Large
if x > 20 :
print('Bigger')
D.Nothing
else :
print('Smaller')
Ans- C
A.Bigger
16)What does it print out after the below
B.Smaller code being excuted?

C.Bigger n=5
Smaller while n > 0 :
n=n–1
D.Nothing print(n)

Ans-B A.5
B.4
C.0
14)write what it prints out after the below
D.-1
code being excuted.
Ans-C
x=6
if x < 2 :
print('Small')
elif x < 10 :
print('Medium')
else :
print('Large')

A.Small

Page 11 of 67
NMUISA Academic Affairs 2021/2022
17)What does it print out after the below
code being excuted? 20)What does it print out after the below
n=5 code being excuted?
while n < 0 : n=5
n=n–1 while n >= 5 :
print(n) n=n–1
print(n)
A.5
B.4 A.5
C.0
D.-1 B.4

Ans-A C.1

18)What does it print out after the below D.0


code being excuted?
n=5 Ans-B
while n >= 0 :
n=n–1 21 ) Given user input of 6, what does the
print(n) program print?
number_str = input("Enter an int:")
A.5 number = int(number_str)
B.4 count = 0
C.0 while number > 0:
D.-1 if number % 2 == 0:
number = number // 2
Ans-D elif number % 3 == 0:
number = number // 3
else: # Line 1
19)What does it print out after the below number = number - 1
code being excuted? count = count + 1
for n in [3, 2, 1] : print("Count is: ",count)
print (n+1)
A.3 A.Count is: 1
2
1 B.Count is: 2

B.1 C.Count is: 3


2
3 D.Count is: 4

C.4 Ans- C
3
2

D.2
3
4

Ans-C

Page 12 of 67
NMUISA Academic Affairs 2021/2022
22 ) Given user input of 5, what does the 24)The output of the statement“print
program print? (round(3.5))”is_________.
A. 3
number_str = input("Enter an int:")
number = int(number_str)
count = 0 B. 3.0
while number > 0:
if number % 2 == 0: C.4
number = number // 2
elif number % 3 == 0:
number = number // 3 D.4.0
else: # Line 1
number = number - 1 Ans-C
count = count + 1
print("Count is: ",count)
25)The output of the statement“print
A.Count is: 1 (int(3.8)+abs(-4)+round(1.8))”is_________.
A. 7
B.Count is: 2
B. 8
C.Count is: 3
C. 9
D.Count is: 4

Ans- D D. 10

Ans-C
23)What does the program print?
26)Whose value does not equal to 3.0?
the_sum = 0
extra = 0 A. 9**0.5
for number in [1,2,3,4,5,6]:
if number%2 and not number%3: B. 9**1/2
the_sum = the_sum + number
print(the_sum)
C. pow(9,1/2)
A.3
D. pow(9,0.5)
B.5
Ans-B
C.9
27) range(5) is _________
D.12 A. [0,1,2,3,4,5]

Ans-A B. [0,1,2,3,4]
C. [1,2,3,4]
D.[1,2,3,4,5]

Ans-B

Page 13 of 67
NMUISA Academic Affairs 2021/2022
28)What’s range of the random number 31)Given the function make odd, what are
created by the expression the results of the function invocation(print
(int(random.random()*900+100)) ? statements)?
A. 0~900
B. 100~900 def make_odd(n):
C. 0~999
D. 100~999 return 2*n + 1
Ans-D
n=3
29)What kind of features does not
print (make_odd(n))
functions provide?

A. Divide-and-conquer problem A. 3
solving B. 4
B. Abstraction and reuse C. 7
C. Simplification and D. 8
readability
D. Increase computing speed Ans-C
and decrease processing time
32)Given the function make odd, what are

Ans-D the results of the function invocation(print

30) Given the function make odd, what statements)?

are the results of the function invocation(print def make_odd(n):

statements)? return 2*n + 1

def make_odd(n): n=3

return 2*n + 1 print (1+make_odd(n))

n=3

print (make_odd( make_odd(3))) A. 3

A. 4 B. 4

B. 7 C. 7

C. 15 D. 8

D. 16
Ans-D

Ans-C
Page 14 of 67
NMUISA Academic Affairs 2021/2022
34)Given x = 'waterwater', what is returned
32)Given the function make odd, what are
by x.replace('w','c')?
the results of the function invocation(print
A. watercater
statements)?
B. caterwater
def make_odd(n): C. catercater

return 2*n + 1 D. waterwater

Ans- C

n=3
35) Which of the following works without
print (1+make_odd( make_odd(3)))
any error?
A. 4
A. var = 'xyz'* 10.5
B. 7
B. var = 'xyz' * '5'
C. 15
C. var = 'xyz' * 5
D. 16
D. var = 'xyz' * 5.0

Ans-D Ans-C

33)my_str = 'Hello' my_str = 'J' + my str[1:] 36)Given a variable S containing a string of

What is the value of my_str? odd length: Write an expression to print the

A. Jello middle character.

B. Hello A. x(len(x)/2)

C. Jllo B. x[len(x)/2]

D. Je C. x[len(x)//2]
D. x(len(x)//3)
Ans-A
Ans-C

Page 15 of 67
NMUISA Academic Affairs 2021/2022
37)Given the following variable assignments: 40 ) Given the string S = "What is your

var_1 = 2.0 var_2 = "apple" name?": What is returned by S[2:8:-1]?

var_3 ='orange' var_4 = 4 What is the output A. empty string


B. a blank space
of the following print statements?
C. "at is "
print("var_3")
D. " si ta"
A. orange
Ans-A
B. var_3
C. 3.0
41)What does the following Python Program
D. 3
print out? fruit = 'banana' aa = fruit.find('z')
Ans-B
print(aa)

38)print ('aa' < 'aaz') A. -1

A. Y B. N

B. True C. null

C. 1 D. error

D. Yes Ans-A

Ans-B
42) What output is produced by Line 1?
39 ) What does the following Python

Program print out?

A. Bbcc
B. abb
C. abc
A. bbcc
D. aabb
B. abb
Ans-C
C. abc
D. aabb
Ans-B

Page 16 of 67
NMUISA Academic Affairs 2021/2022
48)my_str = 'Python Rules!'
43)a_str = 'spam' What is the value of a_str[1]
print (my_str.lower().find('o') ) # Line 1
What output is produced by Line 1 ?
= 'l' ?
Ans-4
A. slam
B. TypeError 49)a_str = 'He had the bat' What is the value
of a_str.find('t',8)
C. spam
D. warning Ans - 13

Ans-B 50) Which line of code can realize the


following requirements.

44)What does the following Python Program There is a test. txt file, open this file in
append mode, and use variable f to
print out?
receive the return value of the file

A.f = open("test.txt", "r")


A. noDiabete B.f = open("test.txt", "w")

B. D C.f = open("test.txt", "a")


D.f = open("test.txt", "r+")
C. Diabete
Ans – C
D. oDiabete

Ans-C 51) The function of the following codes is :


open the test. TXT file, use the variable f to
receive the
45)a_str = 'He had the bat' What is the value
return value and close the file.
of a_str.upper().find('t',8) ?
Plese fill in the line (1) to complete the
Ans - -1
above function
f = open("test.txt", "r")
46)my_str = 'Python Rules!’ What is the
content = f.read()
value of my_str.upper().find('O')? ( line (1) )
Ans- 4
A.f.close()
47)Given: s = 'Mississippi'. What is the B.f.shutoff()
value of s[ : 6 : 2]?
( Quotation marks not included) C.content.close()
Tips: Slicing’s optional third argument D.content. shutoff()
indicates step.

Ans -Msi Ans - A


Page 17 of 67
NMUISA Academic Affairs 2021/2022
52) The function of the following codes is : 54) What do you need to do before using the
open the test. TXT file, use the variable f to rename() function in Python programs?
receive
the return value and close the file. A.import os
Please fill in the line (1) to complete the B.import file
above function C.import rename
f = ( line (1) ) D.import sys
content = f.read()
f.close Ans - A

A.open("test.txt", "r") 55) Which statement of the choices is wrong?


B.file("test.txt").open _________.
C.read("test.txt", "r") A.Lists are mutable, their values can be
D.fileopen("test.txt", "r") changed.
B.The elements of a list must be of the
Ans - A same type.
C.The item of a list can be a list.
53) Which codes can not write "Wow, so D.lists are designated with [ ], with
beautiful!" in the test.txt file? elements separated by commas

A. f = open("test.txt", mode="w") Ans - B


f.write("wow,so beautiful!") Hint :: The elements of a list can be
f.close() different types.
B. f = open("test.txt", mode="r")
f.write("wow,so beautiful!") 56) Which one is empty list?_________
f.close() A.“”
C. = "wow,so beautiful!" B.{}
f = open("test.txt", mode="w") C.[]
f.write(str1) D.()
f.close()
D. f = open("test.txt", mode="a") Ans - C
f.write("wow,so beautiful!") Hint :: Lists are defined by [].
f.close()

Ans - B

Page 18 of 67
NMUISA Academic Affairs 2021/2022
57) For list of a=[1,2,3,4,5,6,7,8,9], which 60) What is the output of the following codes?
indexing is wrong?_________ lst_A =['aaa','bb','c',1,2,3,5.2,True]
A.a[0] print(lst_A[3]+lst_A[4]+lst_A[5])
B.a[9]
C.a[-2] Ans - 6
D.a[len(a)-1]
61) What is the output of the following codes?
Ans - B lst_A =['aaa','bb','c',1,2,3,5.2,True]
Hint :: The length of the list is 9, and the print(sum(lst_A[3:7]))
max index of the list is 8.
Ans - 11.2
58) What is printed out after the following
code being excuted. 62) What is the output of the following codes?
a=['apple','banana','orange','peach'] print lst_A =['aaa','bb','c',1,2,3,5.2,True]
("I like ",a[0],"and",a[-1] ) lst_B = lst_A[3:-1]
print(sum(lst_B)/len(lst_B))
A.I like apple and peach
B.I like apple "and" peach Ans - 2.8
C.I like banana and orange
D.I like banana "and" orange 63) What is the output of the following
codes?
Ans - A lst2= [1,2]*3
print(lst2)
59) Giving a=[2,3] in [1,2,3,4], a is
__________. Ans - [1,2,1,2,1,2]
A.0
B.1 64) What is the output of the following codes?
C.True lst1=[1, 2, 3, 4, 5, 6]
D.False print(print(lst1.pop() ,lst1.pop()))

Ans - D Ans - 6 5
Hint :: There are two elements 2 and 3 in
the list. But there is no element [2,3] in
the list.

Page 19 of 67
NMUISA Academic Affairs 2021/2022
65) Matplotlib can not recognize the 67) Please fill in the ( 1 ) to get the max
following formats to specify black value of BMI of every person :
import numpy as np
A.'b' height = [1.65, 1.6, 1.7, 1.76]
B.'black' weight = [62, 50, 65, 65]
C.(0,0,0) maxBMI = ( 1 )
D.'0'
Ans -
Ans - A max(np.array(weight)/(np.array(height)**
2))
66) Which one will plot the value of x=[1, 3,
2, 4] as the following:

68) Please fill in the ( 1 ) to get the figure of


BMI of every person :

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(4)
A. height = np.array([1.65, 1.6, 1.7, 1.76])
import matplotlib.pyplot as plt weight = np.array([62, 50, 65, 65])
plt.plot(x) bmi = weight / (height ** 2)
plt.show() plt.xticks(x, ('Ankit', 'Hans', 'Joe', 'Flaco'))
B. plt.bar( 1 , color = "b")
import matplotlib.pyplot as plt
plt.line(x)
plt.show()
C.
import matplotlib.pyplot as plt
plt.pie(x)
plt.show()
D.
import matplotlib.pyplot as plt Ans - x, bmi

plt.bar(x)
plt.show()

Ans - A
Page 20 of 67
NMUISA Academic Affairs 2021/2022
69) Given the 72) Matplotlib graphs your data on Figures,
height = [1.65, 1.6, 1.7, 1.76] each of which can only contain one Axes.
weight = [62, 50, 65, 65] A. True
The BMI of every person can be B. False
calculated as the following:
bmi = height/(weight**2) Ans - B. False

A. True 73) Given str_01="Hello World", What is the


B. False value of len(str_01*3)
A.33
Ans - B. False B.11
C.30
70). matplotlib.pyplot is a collection of D.10
command style functions that make matplotlib
work like MATLAB. Ans - A
A. True
B. False 74) Given str_01="Hello+World!", what is the
value of print(str_01[0:5])?
Ans - A. True A.Hello
Reference :: B.Hell
https://matplotlib.org/2.0.2/users/pyplot_t C.Hello+
utorial.html D.hello+

71) plot is a versatile function, and will take Ans - A


an arbitrary number of arguments.
75) Given str_01="PYTHON", What is the
A. True value of len(str_01*3)
B. False
Ans - 18
Ans - A. True
76) Given str_01="Hello, python!", the value
of len(str_01*3) is 40.
A. True
B. False

Ans - B. False
Page 21 of 67
NMUISA Academic Affairs 2021/2022
77) Given numbers=[1,10,6,3] which is the 78) Please use the function open() to read the
value of each group of BMI. "BMI .txt" in the current folder, and extract
Plot a bar chart to show the number of each the information into a List, lst_info. Every
group of BMI as the following. item in the lst_A is the information of one
patient.
Please print and make sure that lst_info[0]
equals to
['135965', '1', '167.5', '73.8', '126','81']
The format of content in "BMI .txt" is
shown as the following :

Ans - import matplotlib.pyplot as plt


plt.clf()
numbers=[1,10,6,3]
labels=
['Underweight','Normal','Overweight','
Obesity']
x=list(range(4)) or x=[1,2,3,4]
plt.bar(x, numbers, 0.4, color="grey")
plt.xlabel("BMI groups") Ans - f=open("BMI.txt")
plt.ylabel("Numbers") #1 i=0
plt.xticks(x, labels) #1 lst_info=[]
plt.title("The numbers of BMI groups") for line in f:
plt.show() lst_line=line[:-1].split("\t")
if i==0:
headline=lst_line
i+=1
print(headline)
else:
lst_info.append(lst_line)
print(lst_info[0])

Page 22 of 67
NMUISA Academic Affairs 2021/2022
79) Please use pandas to read the "BMI.txt" in 80) Given 10 patients' info are saved in a list
the current folder, and extract the information lst_a. Every item in the list is in the format
into a NumPy array, arr_A. Every item in the like ['135965', '1', '167.5', '73.8'], where
arr_A is the information of one patient. '135965' is the id, "1" is the gender. 167.5" is
Please add a new column of the BMI of the height, "73.8" is the weight. Please print
every patient and print the updated data the max value of the BMI and the id of the
frame. patient.
The "BMI.txt" is as the following:
lst_a=
[['135965', '1', '167.5', '73.8', '126', '81'],
['812772', '1', '170', '61', '138', '92'], ['737604',
'0', '157.5', '58.8', '144', '81'], ['822852', '0',
'155', '56.6', '109', '95'], ['494345', '1', '170',
'66.3', '113', '77'], ['283637', '1', '172.5', '81.3',
'122', '73'], ['807595', '1', '163', '65.2', '152',
'96'], ['123777', '1', '162', '55.6', '163', '93']]

Ans -
Ans -
import pandas as pd
max_bmi=0
df = pd.read_csv("BMI.txt",sep='\t')
index=0
df["BMI"]=round(df.weight/((df.height
for i in range(len(lst_a)):
/100)**2),2)
item = lst_a[i]
print(df)
h= float(item[2])/100
w= float(item[3])
bmi= w/(h**2)
if bmi>max_bmi:
max_bmi=bmi
index=i
print(index,max_bmi)

Page 23 of 67
NMUISA Academic Affairs 2021/2022
81) Write what it prints out after the below 84) Which definition of string is not correct?
code being executed. A.s1="Hello World!'
lst_a= [1,2,3,4,5] B.s1="Hello World!"
while len(lst_a)> 0: C.s1='Hello World!'
print (lst_a.pop(), end = ', ') D.s1="""Hello World!"""

A.5, 4, 3, 2, 1, Ans - A
B.5, 4, 3, 2, 1
C.5, 85) Given a variable S="Hello Python", which
D.5 expression can get the character 'o' in the
variable S?
Ans - A
A.S[2]
82) Write what it prints out after the below B.S[4]
code being executed. C.S[3]
D.S[-9]
lst_a = [x for x in range(3)]
for ix in lst_a : Ans - B
print (ix, end = ' ')
86) Giving lst=list(range(4)); b=["123"];
A.0 1 2 lst=a+b, which of the expressions is False
B.1 __________?
C.0
D.1 2 A."123" in lst
B."1" in lst
Ans - A C.1 in lst
D.[1,2] not in lst
83) Giving lst= list(range(10)), a=[1,2,3], the
value of the expression "a in lst" is ______. Ans - B

A.0
B.1
C.True
D.False

Ans - D
Page 24 of 67
NMUISA Academic Affairs 2021/2022
87) Given a variable S="Hello, 90) Which statement of the choices is
Python!" ,Write an expression to print the correct?_________.
middle character ""P"".
A.Lists are immutable, their values can
A.S(len(S)/2) not be changed
B.S[len(S)/2] B.The elements of a list must be of the
C.S[len(S)//2] same type.
D.S[len(S)*0.5] C.The item of a list can be a list.
D.lists are designated with [ ], with
Ans - C elements separated by colon.

88) Given the string S = ""What is your Ans - C


name?"", what is returned by S[1:7:-1]?
91) Which lst is an empty list?_________
A.empty string
B.a blank space A.a=()
C."at is " B.a={}
D." si ta" C.a=[]
D.a=a(0)
Ans - A
Ans - C
89) Which result is True in the following
expressions? 92) For list of a=[1,3,5,7,9], which indexing is
wrong?_________
A."hello"<"Hello"
B."Hello".upper()>'hello' A.a[-1]
C."hello"<="hello1" B.a[5]
D."hello" == "hello" [::-1] C.a[2]
D.a[len(a)-1]
Ans - C
Ans - B

Page 25 of 67
NMUISA Academic Affairs 2021/2022
93) For a list of lst=list(range(1,20,2)), which 96) Given str_01="Hello World", What is the
statement is not correct? value of len(str_01*3)
A.len(lst) = = 10 A.33
B.max(lst)= = 20 B.11
C.min(lst)= =1 C.30
D.lst[len(lst)//2] = = 11 D.10
Ans - A
Ans - B
97) Given str_01="Hello+World!", what is the
94) Given line = 'I like program'; etc = value of print(str_01[0:5])?
line.split(), what is the value of etc[1]? A.Hello
A.a blank space B.Hell
B.like C.Hello+
C."l" D.hello+
D."Program"
Ans - A
Ans - B
98) Given str_01="Hello World", What is the
95) Given line = 'From value of len(str_01*3)
[email protected] Sat Jan 5 A.33
09:14:16 2008', which of the expression is B.11
False? C.30
A.line.startswith('From ') D.10
B.len(line.split())==7
C.len(line.split("@"))==3 Ans – A
D.line.split()[-1]=='2008'
99) Given str_01="Hello+World!", what is the
Ans - C value of print(str_01[0:5])?
A.Hello
B.Hell
C.Hello+
D.hello+

Ans - A

Page 26 of 67
NMUISA Academic Affairs 2021/2022
100) Which line of code can realize the 102) The function of the following codes is :
following requirements. open the test.TXT file, use the variable f to
There is a test. txt file, open this file in append receive the return value and close the file.
mode, and use variable f to receive the return Plese fill in the line (1) to complete the above
value of the file function
A.f = open("test.txt", "r") f = ( line (1) )
B.f = open("test.txt", "w") content = f.read()
C.f = open("test.txt", "a") f.close
D.f = open("test.txt", "r+")
A.open("test.txt", "r")
Ans - C B.file("test.txt").open
C.read("test.txt", "r")
101) The function of the following codes is : D.fileopen("test.txt", "r")
open the test. TXT file, use the variable f to Ans - A
receive the return value and close the file.
Plese fill in the line (1) to complete the above 103) Which codes can not write "Wow, so
function beautiful!" in the test.txt file?
f = open("test.txt", "r") A.
content = f.read() f = open("test.txt", mode="w")
( line (1) ) f.write("wow,so beautiful!")
f.close()
A.f.close() B.
B.f.shutoff() f = open("test.txt", mode="r")
C.content.close() f.write("wow,so beautiful!")
D.content. shutoff() f.close()
C.
Ans - A = "wow,so beautiful!"
f = open("test.txt", mode="w")
f.write(str1)
f.close()
D.
f = open("test.txt", mode="a")
f.write("wow,so beautiful!")
f.close()

Ans - B
Page 27 of 67
NMUISA Academic Affairs 2021/2022
105) Given str_01="PYTHON", What is the
104) What do you need to do before using the value of len(str_01*3)
rename() function in Python programs?
Ans - 18
A.import os
B.import file 106) Given str_01="Hello, python!", the value
C.import rename of len(str_01*3) is 40.
D.import sys
A. True
Ans - A B. False

Ans - B. False

Page 28 of 67
NMUISA Academic Affairs 2021/2022

You might also like