Question: Q 6 : Explain what a local variable is and why it cannot be accessed outside its function. Q 7 : Create a global constant

Q6: Explain what a local variable is and why it cannot be accessed outside its function.
Q7: Create a global constant named DISCOUNT_RATE with a value of 0.1. Write two functions, calculate_discount(price) and calculate_final_price(price). The calculate_discount function should use DISCOUNT_RATE to calculate the discount amount, while calculate_final_price should return the price after applying the discount. Test these functions with different values for price.
Q8: Write a function named square that takes a single parameter, num, and returns the square of that number. Then write a line of code to store and print the square of 8.
Q9: Define a function named calculate_average that takes three test scores as parameters and returns their average. Use this function to calculate the average of three different sets of test scores.
Custom Value-Returning Functions in Complex Expressions
Q 6 : Explain what a local variable is and why it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!