Uploaded by jacksonmofu2

Programming & Data Structures Test

advertisement
COPPERBELT UNIVERSITY
IS 130: Introduction to Programming and Data Structures
TEST ONE
NAME: ………………………………………………. SIN: ………………………….……
Time Allowed: 1 Hour 30 minutes
Answer All Questions (Total Marks: 65)
Section A
1. Assume you have been asked to write a program to calculate and display the gross pay for
an hourly paid employee.
i. Write the pseudo code for this program.
[5 Marks]
ii. Draw the flowchart for this program.
[5 Marks]
2. Suppose you have taken three tests in your IS 130 class, and you want to write a program
that will display the average of the test scores.
i. Write the pseudo code for this program.
[5 Marks]
ii. Draw the flowchart for this program.
[5 Marks]
3. Complete the following table by writing the value of each expression in the Value column.
Expression
Value
i. 6 + 3 * 5
______
ii.
12 / 2 − 4
______
iii.
9 + 14 * 2 − 6
______
iv.
(6 + 2) * 3
______
v.
14 / (11 − 4)
______
vi.
9 + 12 * (8 − 3)
______
vii.
17 % 3
………
viii.
5//2
………
ix.
6 **3
………
[9 Marks]
4. Write a Python statement that subtracts the variable down_payment from the variable total
and assigns the result to the variable due.
[2 Marks]
5. Write a Python statement that multiplies the variable subtotal by 0.15 and assigns the result
to the variable total.
6. What would the following display?
[2 Marks]
[2 Marks]
a=5
b=2
c=3
result = a + b * c
print(result)
7. Write an if statement that checks if the variable a is equal to 1. If it is equal to 1, print a
message saying ‘a equals 1’, else print ‘a is not equal to 1’.
[5 Marks]
8. Write an if statement that checks if the value a lies in the range of 10 to 30 and assigns the
value of the variable a to 20.
[5 Marks]
Section B: Programming Exercises
9. A company has determined that its annual profit is typically 23 percent of total sales. Write
a program that asks the user to enter the projected amount of total sales, and then displays
the profit that will be made from that amount. Hint: Use the value 0.23 to represent 23
percent.
[10 Marks]
10. One acre of land is equivalent to 43,560 square feet. Write a program that asks the user to
enter the total square feet in a tract of land and calculates the number of acres in the tract.
Hint: Divide the amount entered by 43,560 to get the number of acres.
[10 Marks]
Download