Let's code a beginner's Python SLOT MACHINE 🎰

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 87

  • @BroCodez
    @BroCodez  7 місяців тому +45

    # Python Slot Machine
    import random
    def spin_row():
    symbols = ['🍒', '🍉', '🍋', '🔔', '⭐']
    return [random.choice(symbols) for _ in range(3)]
    def print_row(row):
    print("**************")
    print(" | ".join(row))
    print("**************")
    def get_payout(row, bet):
    if row[0] == row[1] == row[2]:
    if row[0] == '🍒':
    return bet * 3
    elif row[0] == '🍉':
    return bet * 4
    elif row[0] == '🍋':
    return bet * 5
    elif row[0] == '🔔':
    return bet * 10
    elif row[0] == '⭐':
    return bet * 20
    return 0
    def main():
    balance = 100
    print("*************************")
    print("Welcome to Python Slots ")
    print("Symbols: 🍒 🍉 🍋 🔔 ⭐")
    print("*************************")
    while balance > 0:
    print(f"Current balance: ${balance}")
    bet = input("Place your bet amount: ")
    if not bet.isdigit():
    print("Please enter a valid number")
    continue
    bet = int(bet)
    if bet > balance:
    print("Insufficient funds")
    continue
    if bet 0:
    print(f"You won ${payout}")
    else:
    print("Sorry you lost this round")
    balance += payout
    play_again = input("Do you want to spin again? (Y/N): ").upper()
    if play_again != 'Y':
    break
    print("*******************************************")
    print(f"Game over! Your final balance is ${balance}")
    print("*******************************************")
    if ___name___ == '__main__':
    main()

    • @MC_Transport
      @MC_Transport 7 місяців тому +1

      Is Bro Code your real name

    • @NerkoVukovic
      @NerkoVukovic 7 місяців тому +1

      line 80, in
      if _name_ == '__main__':
      NameError: name '_name_' is not defined. Did you mean: '__name__'?

    • @MedakitOwO
      @MedakitOwO 7 місяців тому

      ​@@MC_Transportlol it's not it's just an internet alias

    • @MedakitOwO
      @MedakitOwO 7 місяців тому

      ​@@NerkoVukovicjust do '__name__' whenever that happens just follow the error code

    • @user-ze5vx6vf3n
      @user-ze5vx6vf3n 6 місяців тому

      how to repeat input("Do you want to spin again? (Y/N): ").upper() if that is not alpha or not y and n

  • @towsifbillah834
    @towsifbillah834 6 місяців тому +30

    bro is brother, bro is helper , bro is savior, bro is teacher, bro is legend . Love you bro

  • @cantbeserious4120
    @cantbeserious4120 27 днів тому +1

    Thanks Bro. You’re a huge help. I gotta say your videos have to be the easiest to follow and your organization is impeccable.

  • @paraglide01
    @paraglide01 7 місяців тому +12

    Thanks man, projects really help me speed up my learning proces.

  • @cruyffsworld9731
    @cruyffsworld9731 6 місяців тому +2

    Simply the best channel in youtube . straight to the point and no one doesnt understand him .

  • @motomadman573
    @motomadman573 6 місяців тому +7

    Not only did i learn more about coding, i got a free lesson on why not to gamble 😀

    • @kapibara2440
      @kapibara2440 5 місяців тому

      Had the same thought 😊

  • @alan-overthenet
    @alan-overthenet 6 місяців тому +1

    Bro, I really enjoyed this, thank you. I learn and retain by doing projects like this. You are a gem

  • @dmays67
    @dmays67 6 місяців тому

    Much easier to follow for this newbie. Looking forward to coding myself and maybe looking for improvements. Especially loved the use of emojies - it's the pretty colors and noises that keep the punters coming back!

  • @HacknCodeOffical
    @HacknCodeOffical 6 місяців тому +4

    Bro code is my 3rd most favourite coding teacher on entire UA-cam ❤️🔥🗿

    • @spenceragain
      @spenceragain 6 місяців тому

      Who are the other two?

    • @HacknCodeOffical
      @HacknCodeOffical 6 місяців тому

      @@spenceragain 1st code with Harry 2nd the code mentor

  • @TheCommunistRabbit
    @TheCommunistRabbit 6 місяців тому +35

    99% of programmers quit before hitting the subscribe button

    • @b.ka7med114
      @b.ka7med114 6 місяців тому +1

      LET GO GAMBLING
      **strange sound** oh dang it
      **strange sound** oh dang it
      **strange sound** oh dang it
      **strange sound** oh dang it

    • @PersonalEmail-ot1bq
      @PersonalEmail-ot1bq 6 місяців тому

      😂😂

  • @chrisadjei2640
    @chrisadjei2640 3 дні тому

    Awesome video. Don't gamble folks 😂

  • @siciliandragon8654
    @siciliandragon8654 4 місяці тому +2

    Just say bet = int(input("Place your bet amount: ) so you don't have to take the extra step and convert the string.

  • @sreedarshinikannan467
    @sreedarshinikannan467 6 місяців тому +1

    Love all your videos !!! Could you also do tutorials for Flutter pls . Thanks

  • @dariuss.4274
    @dariuss.4274 7 місяців тому +1

    thank you for your tutorials I love your videos

  • @kingshahzad78
    @kingshahzad78 4 місяці тому

    Wowwww.... What a wonderful way of importing fruits
    👌👌

  • @zenogaylord7869
    @zenogaylord7869 6 місяців тому +1

    Bro when are you live on twitch I need to sub to you as a thank you for all these amazing free lessons

  • @cruyffsworld9731
    @cruyffsworld9731 6 місяців тому

    Can u explain algorithms and data structure in python , because ur explanations are the best .

  • @Stace-os6iq
    @Stace-os6iq 6 місяців тому +1

    I love all your work thank you❤️❤️❤️

  • @paraglide01
    @paraglide01 7 місяців тому +1

    Can you show how to do the shortcuts like for random module at 9:00 please.

  • @dysoneducation
    @dysoneducation Місяць тому

    Bro is a genius 🧠🧠🧠👏 thank you

  • @kingshahzad78
    @kingshahzad78 4 місяці тому

    Excellent Job Sir❤❤❤❤

  • @JassersChannel
    @JassersChannel 5 місяців тому +1

    Bro almost became a gambling addict

  • @GamerDevIND
    @GamerDevIND 7 місяців тому +2

    Bro is back to python 😊

  • @enemdes3735
    @enemdes3735 6 місяців тому +1

    This was so fun thanks for video 😂👍

  • @InnnocentladSMCtradinghub
    @InnnocentladSMCtradinghub 7 місяців тому +2

    Sit back relax and enjoy

  • @CrispyandCalmm
    @CrispyandCalmm 7 місяців тому +1

    Thanks Bro Free Education

  • @RajaPatel-h3t
    @RajaPatel-h3t 6 місяців тому +1

    Bro make videos on express js , node js

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    I wish I had someone I could count on in life. I have studied beyond just web design but I'm not getting simple freelance gigs to do. Sometimes I ask myself that is it because I don't have a certificate.

  • @Jordan-qi2dn
    @Jordan-qi2dn 6 місяців тому

    Hey Bro, would you be able to do an updated video of C#?
    And when are you streaming again?!

  • @NightMare-hi7vu
    @NightMare-hi7vu 6 місяців тому

    Bro please make an updated version of the python full course just like the js one

  • @nishawnbeckford2636
    @nishawnbeckford2636 6 місяців тому +1

    Awesome vid

  • @shricharanramesh7149
    @shricharanramesh7149 6 місяців тому +2

    I recreated this program by myself. Thanks bro for this amazing video
    import random
    def create_row():
    return [random.choice(['🍒', '🍉', '🍊', '🔔', '⭐']) for _ in range(3)]
    def print_row(row):
    print("
    ***************")
    print(f" {row[0]} | {row[1]} | {row[2]} ")
    print("***************
    ")
    def bet(balance):
    amount = int(input("Enter the amount to bet : "))
    if amount > balance:
    print("Insufficient funds")
    elif amount < 0:
    print("Amount cannot be negative.")
    else:
    return amount
    return -1
    def pay(row, bet_amount):
    if row[0] == row[1] == row[2]:
    print("You Won!")
    amount_earned = 0
    if row[0] == '🍒':
    amount_earned = 3 * bet_amount
    elif row[0] == '🍉':
    amount_earned = 4 * bet_amount
    elif row[0] == '🍊':
    amount_earned = 5 * bet_amount
    elif row[0] == '🔔':
    amount_earned = 10 * bet_amount
    elif row[0] == '⭐':
    amount_earned = 20 * bet_amount
    else:
    amount_earned = 0
    print(f"Amount Earned : ₹{amount_earned}")
    return amount_earned
    else:
    print("You Lose!")
    return 0
    def main():
    print("-------------------------")
    print(" Slot Machine ")
    print("-------------------------")
    balance = 1000
    running = True
    while running and balance > 0:
    print(f"Your balance : ₹{balance}")
    spin = input("Do you want to spin? (y/n): ")
    if not spin == 'y':
    running = False
    continue
    bet_amount = bet(balance)
    if bet_amount == -1:
    continue
    else:
    balance -= bet_amount
    row = create_row()
    print_row(row)
    balance += pay(row, bet_amount)
    print("Thanks for playing! We looted all your money :)")
    if __name__ == '__main__':
    main()

    • @GayatriMagapu
      @GayatriMagapu 2 місяці тому

      Purpose of return -1 please...?? Actually why did you used in the code

  • @AukeiHD
    @AukeiHD 6 місяців тому

    hey i really love your videos, I was wondering if you could make a video about "matlab".

  • @technicalswag3925
    @technicalswag3925 7 місяців тому

    Sir please continue and complete the react course

  • @osmanldevleti4858
    @osmanldevleti4858 6 місяців тому

    It would be nice if you make a Mongoose video series.

  • @bjrn-magnekristensen2444
    @bjrn-magnekristensen2444 7 місяців тому +1

    ai this gave me insperation want to try it in c, thanks bigbro

  • @s.p_akash
    @s.p_akash 7 місяців тому

    Broo can you make a video about Regular Expressions in Python

  • @exactmidnight
    @exactmidnight 6 місяців тому

    Cool blud keep winning love ya

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    Thank you boss its been a while I guess I have missed a lot

  • @chetranshlasod5157
    @chetranshlasod5157 6 місяців тому

    @BroCodez
    do data structures in panda
    pleasee love ur vids .....
    🙌

  • @jordankerr1
    @jordankerr1 6 місяців тому

    Can you do ISpalindrome method/reverse string in c#?

  • @jadotati7641
    @jadotati7641 7 місяців тому

    Make an assembly course🙂!

  • @eifclub978
    @eifclub978 6 місяців тому

    bro already sound like gigachad

  • @ranz1040
    @ranz1040 6 місяців тому

    Make a go language Playlist please

  • @gordon2161
    @gordon2161 7 місяців тому +1

    Is this going in the 12 Hour course?

    • @olivergrim7634
      @olivergrim7634 7 місяців тому

      its already out several years ago, it will not get added

  • @S.h.a.d.o.w.S.c.r.i.p.t.e.r
    @S.h.a.d.o.w.S.c.r.i.p.t.e.r 7 місяців тому

    Bro Please Explain Django and Flask

  • @naveenshankar-jk2vd
    @naveenshankar-jk2vd 6 місяців тому

    Try to.make videos for node js bro it is a upcoming source library

  • @Bumblevie_
    @Bumblevie_ 6 місяців тому +1

    thanks bro code

  • @melkor1177
    @melkor1177 6 місяців тому

    we need a kotlin tutorial

  • @iDebashish
    @iDebashish 6 місяців тому

    Please Bro do a full course of Kotlin.

  • @ideology8323
    @ideology8323 6 місяців тому

    My bro, help me understand the express node js module!

  • @Yuji_07
    @Yuji_07 6 місяців тому

    like if u want more react tutorial

  • @ChickenNoodleSandwich
    @ChickenNoodleSandwich 7 місяців тому

    GAMBLEING YEAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

  • @mdyusufansari8897
    @mdyusufansari8897 7 місяців тому

    can we add these project in our cv

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    My laptop spoilt so I was not able to follow up with the good content and build my carrier

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    Nothing seems to be working for me. The part of the world I find myself is very tough.

  • @roelroel2k3
    @roelroel2k3 6 місяців тому

    i copied everything but theres a bug in line 49, 45, 8 I'm using python 3.9.6

  • @moegreene3630
    @moegreene3630 6 місяців тому

    You know, only a real Chad would teach people how to code in several languages and end the series by teaching us assembly. Just saying. Throw back languages would be pretty dope. I hear COBOL still has business because of the U.S. banking system and military.

  • @RealSyLol
    @RealSyLol 7 місяців тому

    pls type hinting 4 python

  • @KingXJulien
    @KingXJulien 7 місяців тому

    Kotlin please

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    Nothing seems to be working for me. I'm frustrated in life cuz after all nobody got my back. I have given up my best for this carrier but still.

  • @manavmehta9395
    @manavmehta9395 6 місяців тому

    hey,
    results = []
    for symbols in range (3):
    results.append(random.choice(symbols))
    return results
    this code that you showed as an option outputs object error.

  • @3minutesbibletruth
    @3minutesbibletruth 6 місяців тому

    I need help guys if you can help me in any way to get me a job or get a new laptop for me please I would appreciate. Cuz at this moment only hope is my portion

  • @RayTheBos
    @RayTheBos 6 місяців тому

    Bro Code pls do C++ full course with Unreal Engine (making a game)

  • @spaghetticat110
    @spaghetticat110 7 місяців тому +1

    Gamblemaxxing

  • @Lynx_YTOFF
    @Lynx_YTOFF 6 місяців тому

    🫡🫡🫡🫡🫡🗿

  • @crystallinnen5600
    @crystallinnen5600 6 місяців тому

    __name__