logo

Crowdly

Browser

Add to Chrome

Informatics 1 - Introduction to Programming (2026-2027)[SEM1]

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!

After a successful call to the original function, a student adds: 

print(total) 

outside the function. 

They argue: “The function has run, so total now exists and can be printed here.” 

Explain why this reasoning is incorrect, and identify which variable outside the function holds the returned mean. [2 marks]

View this question

Suppose the call is changed to: 

result = mean([]) 

Explain why the function cannot complete successfully as written. Describe a suitable way for the function to handle this case, and justify your choice. You do not need to write code. [2 marks] 

View this question

Consider: 

scores = {"Asha": 6, "Ben": 4, "Cara": 6, "Dan": 8} 

passed = [] 

distinct_scores = set() 

 

for name in scores: 

    if scores[name] >= 6: 

        passed.append(name) 

        distinct_scores.add(scores[name]) 

 

Explain what values name takes during the loop and what scores[name] retrieves. [2 marks] 

View this question

After the loop finishes: 

  • What is stored in passed?
  • What values are in distinct_scores?
  • Why do these two collections have different lengths? 

You may give the set’s values in any order. [3 marks] 

View this question

The following code now runs: 

saved = distinct_scores 

saved.add(10) 

 

print(10 in distinct_scores) 

State the output and explain why it occurs. [2 marks] 

View this question

Answer these two independent questions: 

  • If saved = distinct_scores.copy() had been used instead, would adding 10 to saved also change distinct_scores? Explain briefly. Assume that 10 was not already present. [1 mark]
  • A student tries to retrieve an element using distinct_scores[0]. Explain why this does not work. [1 mark] 

View this question

State the exact printed output and describe what the program calculates. [2 marks] 

View this question

A student changes the loop to: 

while current <= 7: 

    if current % 2 == 0: 

        continue 

    total = total + current 

    current = current + 1 

The initial values are still current = 1 and total = 0. 

Explain why this version never reaches the print statement. State the values of current and total once the program becomes stuck. [2 marks] 

View this question

Return to the original program. Suppose only the increment is changed to: 

current = current + 2 

Would the final output change? Explain your answer by describing which values of current are processed. [2 marks] 

View this question

Consider: 

current = 1 

total = 0 

 

while current <= 7: 

    if current % 2 != 0: 

        total = total + current 

    current = current + 1 

 

print("Total:", total) 

Complete the table. Record total at the end of the iteration that processes the stated value of current. [2 marks] 

Value of current being processed 

total at the end of that iteration 

3 
4 
5 
7 

View this question

Want instant access to all verified answers on moodle1.maths.ed.ac.uk?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome