Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.42 KB | None | 0 0
  1. #You could do return amount at the end of a function and when you call the function you could do something like balance = deposit() - ping
  2.  
  3. def Withdraw(amount):
  4.      num = input("Withdraw amount: ")
  5.      num = float(num)
  6.      if (num <= amount):
  7.           amount = (amount - num)
  8.      else:
  9.           print ("\nInsufficent funds.")
  10.      print ("\nTotal: $" + str(amount))
  11.      return amount
  12.  
  13. def Deposit(amount):
  14.      num = input("Deposit amount: ")
  15.      num = float(num)
  16.      if (num <= amount):
  17.           amount = (amount + num)
  18.      print ("\nTotal: $" + str(amount))
  19.      return amount
  20.                                        
  21. new_username = input("Please set a username: ")
  22. new_password = input("Please set a password: ")
  23. print ("User saved")
  24.  
  25.  
  26.  
  27. while True:
  28.      print ("\nWelcome to PythonBank. Please enter your account credentials.")
  29.      username = input("\nUsername: ")
  30.      if username == new_username:
  31.                password = input("Password: ")
  32.                if password == new_password:
  33.                          print ("Succesfully logged in as " + new_username)
  34.                          while True:
  35.                               amount = 2000
  36.                               amount = float(amount)
  37.                               print ("")
  38.  
  39.                               operation = input("What would you like to do? \n(Balance, Withdraw, Deposit, Checkings, Savings, Logout): ")
  40.                               operation = operation.lower()
  41.  
  42.                               if operation == ("balance"):
  43.                                    print ("\nTotal: $" + str(amount))
  44.                          
  45.                               if operation == ("withdraw"):    
  46.                                   amount = Withdraw(amount)
  47.                                        
  48.                               if operation == ("deposit"):
  49.                                    amount = Deposit(amount)    
  50.  
  51.                               if operation == ("Checkings"):
  52.                                    print ("Todo")
  53.  
  54.  
  55.                               if operation == ("Savings"):
  56.                                    print ("Todo")
  57.  
  58.  
  59.                               if operation == ("logout"):
  60.                                    break
  61.                                    
  62.  
  63.  
  64.  
  65.                else: print ("\nFailed to login. Please check your spelling and try again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement