Looking for Informatics 1 - Introduction to Programming (2026-2027)[SEM1] test answers and solutions? Browse our comprehensive collection of verified answers for Informatics 1 - Introduction to Programming (2026-2027)[SEM1] at moodle1.maths.ed.ac.uk.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
class Counter:
def __init__(self):
self.count = 0
def increment(self):
self.count = self.count + 1
c = Counter()
c.increment()
c.increment()
print(c.count)
What is printed?
Which correctly defines a function that returns the square of n?
def mystery(x):
y = x * 2
print(y)
What does mystery(3) return?
def greet(name):
return "Hello, " + name
result = greet("World")
print(len(result))
What is printed?
items = [10, 20]
items.append(30)
items[0] = 5
What is the value of items?
Which of the following causes an infinite loop?
total = 0
for i in range(0, 4):
total = total + i
print(total)
What is printed?
x = 4
y = 6
if x * 2 < y or y == 6:
print("A")
else:
print("B")
What is printed?
Consider:
def mean(values):
"""Return the arithmetic mean of the supplied values."""
total = 0
for value in values:
total = total + value
return total / len(values)
result = mean([2, 4, 9])
print(result)
State the exact printed output. In your explanation, identify:
[2 marks]
A student wants to calculate:
result = mean([2, 4, 9]) + 1
They suggest replacing the function’s final line with:
print(total / len(values))
Explain why printing the mean is not a suitable replacement for returning it in this use of the function. [2 marks]