kitomren / likv

0 stars 0 forks source link

text based input module #25

Open kitomren opened 2 weeks ago

kitomren commented 2 weeks ago

interactive module to edit and update posts.data list posts edit post: prompt for all the fields new post: prompt for all the fields copy post delete post

kitomren commented 1 week ago

skeleton that probably be used for version 0.1 ´´´

Python Banking Program

def show_balance(balance): print("") print(f"Your balance is ${balance:.2f}") print("")

def deposit(): print("") amount = float(input("Enter an amount to be deposited: ")) print("") if amount < 0: print("") print("That's not a valid amount") print("") return 0 else: return amount

def withdraw(balance): print("") amount = float(input("Enter amount to be withdrawn: ")) print("")

if amount > balance:
    print("*********************")
    print("Insufficient funds")
    print("*********************")
    return 0
elif amount < 0:
    print("*********************")
    print("Amount must be greater than 0")
    print("*********************")
    return 0
else:
    return amount

def main(): balance = 0 is_running = True

while is_running:
    print("*********************")
    print("   Banking Program   ")
    print("*********************")
    print("[1.Show](https://www.youtube.com/redirect?event=comments&redir_token=QUFFLUhqbGg4NllRS1BJZzNxRk41QnhIQ05vbm4zTGRzZ3xBQ3Jtc0trdzJ3bnRqc3dYa1VRUk9KWWlBX2xsaVRwT21IZVBTUUljcW9QbU14RzZ1WTB6emt5ajVXZ24xMFBDNHRidHBGcXMwVUlqSmg0S1RJLWpKQkVUdjNYWHYyRHBhSlpjLVVIdzlxNk1ydWZoSm9HWVhaYw&q=http%3A%2F%2F1.show%2F) Balance")
    print("2.Deposit")
    print("3.Withdraw")
    print("4.Exit")
    print("*********************")
    choice = input("Enter your choice (1-4): ")

    if choice == '1':
        show_balance(balance)
    elif choice == '2':
        balance += deposit()
    elif choice == '3':
        balance -= withdraw(balance)
    elif choice == '4':
        is_running = False
    else:
        print("*********************")
        print("That is not a valid choice")
        print("*********************")

print("*********************")
print("Thank you! Have a nice day!")
print("*********************")

if name == 'main': main() ´´´ 138

Svar