Answered step by step
Verified Expert Solution
Question
1 Approved Answer
QUESTION 2 a. Answer the questions related to the following function: (4 marks) def mystery (a, b, c, e): x=a y=b x=x+1 y=y*2 return x+y+e
QUESTION 2 a. Answer the questions related to the following function: (4 marks) def mystery (a, b, c, e): x=a y=b x=x+1 y=y*2 return x+y+e . What would be a good name for the function instead of mystery? (1 mark) Is the function a void function or a value returning function? (1 mark) How many parameters (arguments) does it specify? Can the list of arguments be simplified? If yes, how? (1 mark) How many local variables is the function using? How can these variables be accessible from outside the function? (1 mark) . . b. Write a python function called occurrences that takes as parameters: an integer number n (the size or length of the list), a list of n integers and a number x. (6 marks) The function should return the number of occurrences (the number of repetitions) of x in the list. (4 marks) Use the function in a program and show its execution. (2 marks) . Note: Your programs should not use any of the built-in functions of list. For b, you should add a screenshot of the code execution
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