Answered step by step
Verified Expert Solution
Question
1 Approved Answer
LDN Question 1 Describe the building blocks of computers and programs based on your understanding and answer this question. You are given the following code
LDN Question 1 Describe the building blocks of computers and programs based on your understanding and answer this question. You are given the following code segments: (a) 1- def addi(a, b): 2 a = a + b 3 print('In addi: , a, b) 4 5- def add2(a, b): 6 a.append(b) 7 print('In add2: ', a, b) 9-def main(): 10 a = [1] 11 b = [2] 12 addi(a, b) print("In main: ', a, b) a = [1] b = [2] 16 add2(a, b) print('In main: ', a, b) 18 19 main() 8 13 14 15 17 (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 (1) (4 marks) (b) 1 a, b = 1,9 2 while True: 3 if abs(a * a - b)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started