Let's code a beginner's Python BANK PROGRAM 💰

#python #pythonprogramming #pythontutorial
This is an exercise do help us learn about functions in Python. Code for this program is pinned in the comments section down below.

Пікірлер: 94

  • @BroCodez
    @BroCodezАй бұрын

    # 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 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 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 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()

  • @user-ep2oc1bx3n

    @user-ep2oc1bx3n

    Ай бұрын

    how about stopwatch program

  • @Foggydew931

    @Foggydew931

    Ай бұрын

    Thanks, this is great content for learning.

  • @cybericanthecoder
    @cybericanthecoderАй бұрын

    Wow! Amazing little course. Loved it! Please make more like this, I'm a beginner, so I would appreciate it. Your content and channel are awesome! Looking forward to a another mini course. You Rock!

  • @someMF_XD
    @someMF_XDАй бұрын

    I'm glad Bro posted another great video !

  • @robertcabuto3284
    @robertcabuto3284Ай бұрын

    I wish my bank's website was like that - just the basics - without so many ads.

  • @Deondree
    @DeondreeАй бұрын

    Bro you need to give a tutorial on api’s I need help with it and there’s no other guy that can explain stuff like you do

  • @EpicZeus
    @EpicZeusАй бұрын

    Man this in java would have been like 200 lines lmao

  • @aguyontheinternet1

    @aguyontheinternet1

    Ай бұрын

    86 Lines total. (compared to 71 in python) 55 Lines if you take a minute to "optimize it for space" (remove whitespaces and some repeated print statements) Could 100% be brought down even further by more optimization ~~~~~~~~~~~~~~~~~~~ import java.util.Scanner; class Bank { static Scanner scan = new Scanner(System.in); public static void showBalance(float balance) { System.out.println("*********************"); System.out.println("Your balance is $" + String.format("%.2f", balance)); System.out.println("*********************"); } public static float deposit() { System.out.println("*********************"); System.out.println("Enter an amount to be deposited: "); float amount = Float.parseFloat(scan.nextLine()); System.out.println("*********************"); if (amount System.out.println("*********************"); System.out.println("That's not a valid amount"); System.out.println("*********************"); return 0; } return amount; } public static float withdraw(float balance) { System.out.println("*********************"); System.out.println("Enter an amount to be withdrawn: "); float amount = Float.parseFloat(scan.nextLine()); System.out.println("*********************"); if (amount > balance) { System.out.println("*********************"); System.out.println("Insufficient funds"); System.out.println("*********************"); return 0; } else if (amount System.out.println("*********************"); System.out.println("Amount must be greater than 0"); System.out.println("*********************"); return 0; } return amount; } public static void main(String[] args) { float balance = 0; boolean running = true; while (running) { System.out.println("*********************"); System.out.println(" Banking Program "); System.out.println("*********************"); System.out.println("1. Show Balance"); System.out.println("2. Deposit"); System.out.println("3. Withdraw"); System.out.println("4. Exit"); System.out.println("Enter your choice (1-4): "); String choice = scan.nextLine(); if (choice.equals("1")) { Bank.showBalance(balance); } else if (choice.equals("2")) { balance += Bank.deposit(); } else if (choice.equals("3")) { balance -= Bank.withdraw(balance); } else if (choice.equals("4")) { running = false; } else { System.out.println("*********************"); System.out.println("That is not a valid choice"); System.out.println("*********************"); } } System.out.println("*********************"); System.out.println("Thank you! Have a nice day!"); System.out.println("*********************"); } }

  • @cleevensluxama1242

    @cleevensluxama1242

    Ай бұрын

    in Java it will run faster lmao

  • @jjgg2627

    @jjgg2627

    Ай бұрын

    @@cleevensluxama1242By a few secs smh.

  • @namelessbrown

    @namelessbrown

    Ай бұрын

    ​@@cleevensluxama1242For this program, it doesn't matter how fast. Humans wouldn't even recognize the difference.

  • @user-yi4ts3tr7w

    @user-yi4ts3tr7w

    Ай бұрын

    ​@@cleevensluxama1242with faster and stupid errors

  • @3549119
    @3549119Ай бұрын

    too much value in this channel bro... i 'm from brazil, i am turn into a very big fa and new student member. thanks for all this knowledge for FREE! Have no words ..

  • @paraglide01
    @paraglide01Ай бұрын

    Thanks man great beginner project, keep em coming.

  • @avtandil5433
    @avtandil5433Ай бұрын

    Thank you for your job Bro!

  • @francismannion7075
    @francismannion7075Ай бұрын

    Thank you for a very interesting lesson.

  • @bhargavram4027
    @bhargavram4027Ай бұрын

    welcome back chad! Missing you sooo much

  • @mohamedcoufi9873
    @mohamedcoufi987317 күн бұрын

    Simple n easy thank you

  • @adventureDad1976
    @adventureDad197618 күн бұрын

    Great job!!

  • @DANNYEL20122
    @DANNYEL20122Ай бұрын

    I love your channel

  • @being5033
    @being503315 күн бұрын

    thanks. appreciate a lot!

  • @lindadelalifiasam5878
    @lindadelalifiasam58786 күн бұрын

    😊😊😊love this lesson

  • @Om-jo8eu
    @Om-jo8euАй бұрын

    Thanks Bro!

  • @Franck-kb7np
    @Franck-kb7npАй бұрын

    Vraiment un Super Bro👍

  • @maathmatics
    @maathmaticsАй бұрын

    Great

  • @lukchem
    @lukchemАй бұрын

    I personally would add an try except around the inputs so the program doesn’t crash when the user types a String instead of a number in the input.

  • @DeejayRobert
    @DeejayRobertАй бұрын

    Bro did the thing.

  • @kedarppopuri2776
    @kedarppopuri2776Ай бұрын

    Bro love you 💖.

  • @daytodaylocal1398
    @daytodaylocal1398Ай бұрын

    Wao its great

  • @PedroRodriguez-dl5yt
    @PedroRodriguez-dl5yt5 күн бұрын

    Hey, how good to see ya

  • @ghostloggs
    @ghostloggsАй бұрын

    Thanks man

  • @jordan5652
    @jordan5652Ай бұрын

    can you go over a more modern gui for python please when you get time.

  • @GfoxSim
    @GfoxSimАй бұрын

    WOW, great Python project. Could you please cover Unit Testing in one of the videos, perhaps for this specific project. Unit Testing makes it easier to test projects and speeds up the development process. If you've already covered it, please link me to the video.

  • @gunjanmali3766
    @gunjanmali37666 күн бұрын

    thank you sir

  • @attohval
    @attohvalАй бұрын

    Thank you so much. Please can you do a video for GUI on Python?

  • @unexplainablefish52
    @unexplainablefish52Ай бұрын

    That negative money 420.69 got me rollin hahaha

  • @pramodhkumar8771
    @pramodhkumar8771Ай бұрын

    Thanks bro. Can you start tutorial on Golang .

  • @marcinzale
    @marcinzaleАй бұрын

    Please record such a video but with datya saving function to e.g. SQLlite, Firebase or at least a file. Now when you close the program, the data is lost. It will be more useful and close to real life. Anyway, thanks.

  • @nialld2638
    @nialld263829 күн бұрын

    Your videos are brilliant, they have been a great help. How would a person get this up onto their website as in how would yiu deploy it for an end user?

  • @leonaise7546
    @leonaise7546Ай бұрын

    Can you do a lesson on modules & packages?

  • @user-yl4wy3bp1e
    @user-yl4wy3bp1e15 күн бұрын

    Wow

  • @tentimesful
    @tentimesfulАй бұрын

    lol this is first year of programming did in in java without no knowledge in programmihng. but my teacher told me to use more methods or he wont help me if it didnt works as my program so complicated... but succeeded though for the class lol... but eventually i learned if you methodize everything then you can edit add or fix very fast.... believe me you dont want to read and update a code that is very big without methods with meaning... visual studio made it cool though you can select a code and say methodize and it selects the variables needed for that method and methodize it with the code you selected, very handy

  • @technicalswag3925
    @technicalswag3925Ай бұрын

    Sir please continue and complete the react course

  • @user-vs9dk9bw3v
    @user-vs9dk9bw3vАй бұрын

    Hey bro any thoughts about making videos on backend development soon?

  • @amitkumarverma369
    @amitkumarverma369Ай бұрын

    Bro can do some tutorial on financial modelling with python

  • @ProfShibe
    @ProfShibeАй бұрын

    yippeeeee

  • @user-ir5sl3so8d
    @user-ir5sl3so8dАй бұрын

    Hey bro!!! can you post a video on ML and AI

  • @Norro_o
    @Norro_oАй бұрын

    pls make a video about explaining grid in css🙏🙏

  • @KenStackTechnologies
    @KenStackTechnologiesАй бұрын

    Its working. Thank u

  • @Nishanth_S

    @Nishanth_S

    Ай бұрын

    what 😂, who are you 😂😂 🃏 Seems like you are here for your intership project or final year project. Just learn the concept bro. don't copy the code 🃏

  • @_Aronix_

    @_Aronix_

    19 күн бұрын

    hey the majority of python developers. you speak for the majority of programmers? wow he should have known!​@@Nishanth_S

  • @chandrasekarkrishnasamy7197
    @chandrasekarkrishnasamy7197Ай бұрын

    Hi, I am 57 years old. I run my first successful code because of you ❤

  • @mohammadsami5579

    @mohammadsami5579

    29 күн бұрын

    jabarjast 👍

  • @mohammadsami5579

    @mohammadsami5579

    29 күн бұрын

    r u from India ?

  • @revanthreddy790
    @revanthreddy790Ай бұрын

    hey can you follow with a video adding more python functionality such as using some bank api to send notifications of bank balance (like emails) everyday so we are aware on a daily basis of what our balance is and how much we spent in the day?

  • @kedarppopuri2776
    @kedarppopuri2776Ай бұрын

    AND Please Conside doing a django Tutorial man.

  • @DivyanshuJain-nw3ts
    @DivyanshuJain-nw3tsАй бұрын

    Plz make a Django Full course🙏

  • @quangquyennguyen9390
    @quangquyennguyen9390Ай бұрын

    You have a plan for Go or typescript, Bro?

  • @whislevarshan3752
    @whislevarshan375226 күн бұрын

    00:01 Creating a simple banking program using Python. 01:31 Creating a bank program and taking user input for banking options. 03:36 Handle invalid input with else statements 05:17 Creating functions to handle balance display and deposit. 07:17 Updating the deposit function to handle negative deposits and returning a valid amount 09:15 Validate user input and handle withdrawal process 11:15 Enclosing the main portion of code within a function for better readability and maintainability. 12:47 Pass balance to withdraw and show functions

  • @astra8538
    @astra8538Ай бұрын

    Would have been useful for the computer science project I had 7 months ago 😂

  • @VishwanathK-mv6gj
    @VishwanathK-mv6gjАй бұрын

    Hi bro code , can you teach about database in python

  • @razor20san
    @razor20sanАй бұрын

    1.Show nice blue

  • @RocketWR
    @RocketWRАй бұрын

    hi :)

  • @VincentFerrara-zp3gc
    @VincentFerrara-zp3gcАй бұрын

    What code editor do you use?

  • @амогус7_8

    @амогус7_8

    Ай бұрын

    pycharm

  • @SabonaMarara
    @SabonaMararaАй бұрын

    thanks bro code . how to connect mongodb ?

  • @Bacon_editsz
    @Bacon_editszАй бұрын

    Is it possible you nest multiple functions into one function like less i made a function called bank function could put the these functions under one function

  • @johnstephens2412

    @johnstephens2412

    Ай бұрын

    A class is better

  • @Bacon_editsz

    @Bacon_editsz

    Ай бұрын

    @@johnstephens2412 thx ill go learn classes

  • @Sav2Swindle
    @Sav2SwindleАй бұрын

    pls type hinting 4 python

  • @TheSkarabeush
    @TheSkarabeushАй бұрын

    Which banking app or cash machine will let you withdraw negative amount???

  • @shortthink.
    @shortthink.14 күн бұрын

    Ledgen

  • @mr.blebberson4439
    @mr.blebberson4439Ай бұрын

    it keeps saying that the variable "Balance" is undefined...1 edit: and the else is also having problems. on line 16

  • @ideology8323
    @ideology8323Ай бұрын

    Bro I don't know nodeJs, pls help me

  • @user-kh5tt7qz6r
    @user-kh5tt7qz6rАй бұрын

    hi bro please of you see my comment answer me : did you know how can i write a leveling ? like RPG leveling for ranking the users? such as to day trend in telegram crypto bots based on tap mining? please if any one know ho to make a leveling system answer me

  • @dfytq
    @dfytq19 күн бұрын

    Dear Beginers, Bank will never allow python for their system. If you want to learn that's okay. But don't even imagine bank will hire you to write python code for them.

  • @jakubwiszowaty5118

    @jakubwiszowaty5118

    10 күн бұрын

    So what would a bank allow?

  • @dfytq

    @dfytq

    9 күн бұрын

    @@jakubwiszowaty5118 java, .net, kotlin, golang. Python for machine learning.

  • @noob_op8828
    @noob_op8828Ай бұрын

    H

  • @VincentFerrara-zp3gc
    @VincentFerrara-zp3gcАй бұрын

    What code editor do you use?

  • @maushgw

    @maushgw

    Ай бұрын

    This is PyCharm

Келесі