Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me solve me the questions down below: A program is read by computers (Python interpreters) and programmers, and sometimes many programmers. It is
Please help me solve me the questions down below:
A program is read by computers (Python interpreters) and programmers, and sometimes many programmers. It is important to write programs that are readable. A readable program is easy to understand by a human. It is a bad practice to use meaningless identifier like single character as variable name. It is even worse to have too many identical identifiers as both global variable outside a function definition and local variable inside a function definition, but they have entirely different meaning. A student has submitted a program using a lot of unclear variable identifiers. Please help the teachers to understand this program. (i) Is there any error when executing this program? If there is no error, write down the output of the program (ii) Study line 6 . The identifier a is used as the name of a function. The same identifier a is also used as a local parameter variable. Explain why it is not a problem. (iii) Study line 7. what is the purpose of putting global in front of the variable c? What will be the difference in the situation of the variable c if the keyword global is not exist like the situation in line 16 ? Submit q1g.txt. [4 marks] Make reference to the same program as in the previous part. State the scope (using line numbers) of the following variables. The scope may be made up of disconnected regions. State whether the variable is a global variable or local variable. For example, the variable c at line 3 has scope from 4 to 21 except 16 and 17 and it is a local variable. (i) The variable c at line 7 (ii) The function a() at line 6 (iii) The variable a at line 6 (iv) The variable a at line 8 Submit your solution in q1h.txt. [4 marks]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