0% found this document useful (0 votes)
13 views2 pages

Fa Ict As 10

The document contains practice questions for a final assessment, focusing on programming concepts and code behavior. It includes code segments with multiple-choice answers, user input scenarios, and explanations of potential issues in the code. The questions aim to help students prepare for the final exam, although they may not cover every possible topic or question type.

Uploaded by

osmanovr196
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)
13 views2 pages

Fa Ict As 10

The document contains practice questions for a final assessment, focusing on programming concepts and code behavior. It includes code segments with multiple-choice answers, user input scenarios, and explanations of potential issues in the code. The questions aim to help students prepare for the final exam, although they may not cover every possible topic or question type.

Uploaded by

osmanovr196
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/ 2

Final Assessment Practice Questions. Formative assessment.

Note that while these questions are great practice for the final exam, they do not necessarily cover ever
topic or question type that could appear on the exam. You are strongly encourage to do additional
studying beyond completing these questions.
1. Consider the following code segment:
a = "12"
b = 8
print(a + b)

When this program runs:


A. It will display 20
B. It will display 128
C. It will display 12, 8
D. It will display 812
E. None of the above answers are correct
Answer: E

2. Consider the following code segment:

m = int(input())
n = int(input())

if (m < n):
print("A")
elif (m > n) and (m == 0):
print("B")

if (n == 0):
print("C")
else:
print("D")

a) If the user enters 0 for m and -4 for n then the output will be: BD

b) If the user enters 0 for m and 0 for n then the output will be: C

c) If the user enters 0 for m and 1 for n then the output will be: AD

d) If the user enters 1 for m and 0 for n then the output will be: C

3. Consider the following code segment:

i = 1
value = 0

while i < 32:


for j in range(1,i):
value = value + 1
i = i * 2
print(value)
a) The first value printed out by this code segment will be: 0

b) The second value printed out by this code segment will be: 1

c) The third value printed out by this code segment will be: 4

d) The total number of values that will be displayed by this code segment will be: 5

4. Consider the following program. It totals 10 numbers entered by the user and reports if the total is
less than, equal to, or greater than 1.0.

total = 0.0

for i in range(0,10):
v = float(input("Enter a value: "))
total = total + v

if total < 1.0:


print("Your total is less than 1.0")
elif total == 1.0:
print("Your total is exactly 1.0")
else:
print("Your total is greater than 1.0")

a) When I run the program and enter the numbers 0.2, 0.2, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.1 and 0.1, the
program correctly reports that these numbers total exactly 1.0. However, if I enter the numbers 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 and 0.1, the program incorrectly reports that the total is less than
1.0, even though the sum of the numbers is exactly 1.0. What is causing the program to behave
incorrectly in this case?

If elif else are not inside this cycle

b) Briefly describe how you could prevent the program from incorrectly reporting that the second sum
is less than 1.0. What problem could your change introduce?
converted to upper case.
Put them
inside the
cycle

You might also like