PHYTON 3 HELP! What is the scope of: i. number_of_trial_days ii. total_cost iii.
ID: 3841253 • Letter: P
Question
PHYTON 3 HELP!
What is the scope of:
i. number_of_trial_days
ii. total_cost
iii. cost1
Explain your answers please!
1 def cost-of-attorney number-of-trial-days price-per-day number-of-witnesses, price-per-witness) Computes the cost of an attorney which is in dollars number-of-trial days the number of days the trial lasts price-per-day cost of an attorney working for 1 day in dollars number of witnesses how many witnesses need to be CrOSS examined during the trial price-per-witness price of an attorney per witness that needs to be cross examined in dollars Returns total cost of an attorney 14 15 total-cost-per-day number-of-trial days price-per-day 16 total witness-cost number-of-witnesses price-per-witness 17 total-cost total cost-per-day total-witness-cost return total cost 20 compute the cost of a trial that lasts 2 days, 21 each day costs 600$, there are 3 witnesses, and it costs 100$ per witness 22 cost 1 cost-of-attorney (2 600 3, 100 24 compute the cost of a trial that lasts 9 days 25 each day costs 400$, there are 13 witnesses, and it costs 100$ per witness 26 cost cost-of-attorney (9 400 13 100)Explanation / Answer
i. number_of_trial_days - This variable is defined inside a function. So it is a local variable and becomes unavailable when the function execution gets over.
ii. total_cost - This variable is defined inside a function. It is still a local variable but it's scope is very less (up to two lines in this function).
iii. cost1 - This is a global variable available which can be used after its declaration point in any function i.e any number of functions defined and declared after line 22 can make use of this variable.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.