Jun-22-2020, 03:23 PM
Hi everyone.
First and foremost I should say that I am a beginner and right now I am analyzing and trying to understand this code. As you can see is a kind of ATM. I see that is made of a bunch of functions to tackle all the logic. I have looked for information about some terms (return, True, False, not ok) and I have read and understood the
definition. But it´s kind of difficult to understand How it works in a code. I need to be clear with that to continue.
When I end a function with "return True" and/or "return False", what does these exactly mean? where those values store? (it supposed that "return" send a value but we need a variable to store it) That happen for example in
def userValidation(u,c); def withdraw(value); def deposit(value); def action(option)
In def deploy() I don´t understand what is the purpose of the line "ok, balanceInBd = action(option)".
Maybe for most of you my questions have obvious answers, but as I told you, I am a beginner and I am learning by reading and coding.
Thanks in advance.
PD. English in process, sorry for grammar mistakes.
First and foremost I should say that I am a beginner and right now I am analyzing and trying to understand this code. As you can see is a kind of ATM. I see that is made of a bunch of functions to tackle all the logic. I have looked for information about some terms (return, True, False, not ok) and I have read and understood the
definition. But it´s kind of difficult to understand How it works in a code. I need to be clear with that to continue.
When I end a function with "return True" and/or "return False", what does these exactly mean? where those values store? (it supposed that "return" send a value but we need a variable to store it) That happen for example in
def userValidation(u,c); def withdraw(value); def deposit(value); def action(option)
In def deploy() I don´t understand what is the purpose of the line "ok, balanceInBd = action(option)".
Maybe for most of you my questions have obvious answers, but as I told you, I am a beginner and I am learning by reading and coding.
Thanks in advance.
PD. English in process, sorry for grammar mistakes.
def login(): user=input("User: ") password=input("Password: ") return userValidation(user,password) def userValidation(u,c): if u.lower()==userInBd and c==passwordInBd: return True return False def deploy(): if not login(): print("Invalid user or Password") return print("Choose a operation: ") option = int(input("1. Deposit or 2. Withdraw: ")) ok, balanceInBd = action(option) if not ok: print("Not enough money. Balance: ", balanceInBd) else: print("Successful Process. New Balance: ", balanceInBd) def withdraw(value): if value>balanceInBd: return False, balanceInBd return True, balanceInBd-value def deposit(value): return True, balanceInBd+value def action(option): if option ==1: value = int(input("Deposit amount: ")) return deposit(value) if option==2: value = int(input("Withdraw amount: ")) return withdraw(value) return False, balanceInBd deploy()