Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions