Sep-09-2024, 03:45 AM
(Sep-06-2024, 02:49 PM)deanhystad Wrote: [ -> ]your post
@deanhystad
Arigato gozaimus.
Does LEGB refer to variable/function names/values and their accessibility. So ...
L (local) would refer to a variable and its value as computed by a particular function that's sequestered/isolated away from the rest of the program. (Vide infra)
def addition(a, b): total = a + b return total addition(2, 3) print(total)In the above program (adding 2 numbers), the print(total) command would return an error because total is outside its scope? Is it correct to say that the a given variable is outside the scope of a command/function.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
G (global) variables are those that are "outside" all function calls and their value can be accessed by the entire program, si? Vide infra
weight_apples = 3 weight_bananas = 4 heavier = max(weight_apples, weight_bananas) def price_total(weight_apples, weight_bananas): price_apples = weight_apples * 5 price_bananas = weight_bananas * 4 amount = price_apples + price_bananas return amount print(price_total(weight_apples, weight_bananas))-----------------------------------------------------------------------------------------------------------------------------------------------------------------
E (Enclosed) variables (and their values) is something I don't understand. Are we talking about nested functions (vide infra)?
compute_cost(compute_volume(length, width, breadth))

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
B (built in) refers to Python-reserved names like maxand min and print and for, correct? We can't use them as variable names.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Seeking clarification on the above.