Pass as parameter
You can put the variable "mts_squares" as parameter in the function "prog_main" and then pass the function "Prog" as parameter to "prog_main" and put the return of "Prog" to the variable "mts_squares", as in the example below:
def prog():
print("Informe o valor: ")
cli()
mts_quadrados = int(input(":"))
clr()
return mts_quadrados # retorna o valor
def prog_main(mts_quadrados):
qtd_lata = int(mts_quadrados / 6)
vlr_lata = float(qtd_lata * 80)
prog_main(prog()) # o retorno de "prog" e passado como parâmetro para "prog_main"
Using the global reserved word
Using the word reserved global
at the beginning of the function Python understands that that variable is global in scope.
mts_quadrados = 0
def prog():
global mts_quadrados
print("Informe o valor: ")
cli()
mts_quadrados = int(input(":"))
clr()
def prog_main():
global mts_quadrados
qtd_lata = int(mts_quadrados / 6)
vlr_lata = float(qtd_lata * 80)
How to use a global variable in a function other than the one that created it?
You want to send the variable "square mts_squares"?
– Wictor Chaves