Question: Describe the building blocks of computers and programs based on your understanding and answer this question. You are given the following code segments: 1
Describe the building blocks of computers and programs based on your understanding and answer this question. You are given the following code segments: 1 def add1(a, b): (a) 2 3 4 a = a+b print('In add1: ', a, b) 5e def add2(a, b): 6 7 8 a.append(b) print('In add2: ', a, b) 9 def main(): 10 a = [1] 11 b = [2] 12 add1(a, b) 13 print('In main: ', a, b) 14 a = [1] 15 b = [2] 16 add2(a, b) 17 print('In main: ', a, b) 18 19 main() (i) What is the output of the code segment when it is executed? (4 marks) Explain in terms of assignment statements and mutability, the output you gave for part (i). (4 marks) (b) (c) (i) (ii) 1 a, b 1, 9 2 while True: 3 456 if abs(a * a- b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
