Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please answer these questions Section A Answer ALL questions in this section Question 1 (20 marks) A programmer, new to Python, has produced the following
please answer these questions
Section A Answer ALL questions in this section Question 1 (20 marks) A programmer, new to Python, has produced the following piece of code to work out and store the first 5 multiples of u in a list by two methods: #Import required external modules import numpy import math #Initialise two strings to hold the calculated values list Pil = (1 list Pi2 = 1 numPi = 0 # initialise numi #Define Functions def appNpiToStr (list, listEntry): Function to append value within function'' list.append(listEntry) def ni (num): Function to calculate new value to be appended outside of function'' numPi = num*maths.pi return listNum = (1,2,3,4,5) listLen = len(listNum) #Attempt 1 using appNpi ToStr for i in range (listLen): appNpiToStr (listPil, listNum[i]*maths.pi) print('The values from appending within the function call are in', listPil) #attempt 2 using ni to calculate n'pi for i in range (listlen): nPi(listNum[i]) listPi2.append(numPi) print(" The values from appending outside the function call are ', listPi2) Unfortunately, this produces the following error: NameError Traceback (most recent call last)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