Professional Documents
Culture Documents
Quiz Session 9 - Answers
Quiz Session 9 - Answers
NPM :_______________________
Multiple Choices
1. What gets printed when Python execute 5. What will be the output after the
the following program? following statements?
a) List
3. What will Python produce if the following b) String
line is executed? c) Dictionary
d) Tuple
c) BlockC Answer:
d) BlockD
1.
2.
9. What is the output of the following
program? 3.
4.
5.
6.
7.
a) 0 8.
1
9.
2
3 10.
b) 0
2
1
3
c) 0
1
2
4
d) 0
2
1
4
a) 67
b) 678
c) 679
d) 6789
Name :_______________________
NPM :_______________________
Short Essays
Answer:
10
11
b. Answer:
a.
It’s small.
b.
Answer:
It’s an odd number.
5:0
It’s small.
5:1
c.
5:2
It’s an even number.
6:0
It’s medium
6:1
d.
6:2
It’s an odd number.
It’s big.
It’s medium.
Name :_______________________
NPM :_______________________
Long Essays
1. In a particular jurisdiction, taxi fares consist of a base fare of $4.00 for the first distance of 0-2
kilometers, and $0.25 for every 140 meters traveled afterwards. Write a program that takes the
distance traveled (in kilometers) as its only parameter and returns the total fare as its only
Answer:
#InputSection
cap = 2
base_fare = 4
rate = 0.25
dis_rate = 140
convert = 1000
#ComputationSection
total_fare = base_fare
else:
if ((distance-cap)*convert)%dis_rate == 0:
else:
#OutputSection
result.
2. You have just started a sales job in a department store. Your pay consists of a base salary plus a
commission. The base salary is $1,000. The following scheme shows how to determine the
commission rate:
Write a program that returns your total pay if you input the sales amount.
Answer:
#InputSection
base_salary = 1000
cap_1 = 5000
cap_2 = 10000
rate_1 = 0.08
rate_2 = 0.10
rate_3 = 0.12
#ComputationSection
else:
#OutputSection
3. Suppose that the tuition for a university is $X this year and increases r% every year. Write a
program that determines the doubling time (minimum number of years that the tuition would
have doubled). Note: X and r are inputs in float.
Answer:
#InputSection
year = 0
tuition_end = tuition_beg
#ComputationSection
year += 1
tuition_end = tuition_end*(1+rate)
#OutputSection