ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

DICE ROLLER program in Python ⚂

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 พ.ย. 2022
  • #python #tutorial #course
    Here are the Unicode characters I use for drawing the dice.
    TH-cam has strange spacing, so the ASCII art looks warped in the description.
    It should still work if you copy and paste it into PyCharm.
    ● ┌ ─ ┐ │ └ ┘
    import random
    dice_art = {
    1: ("┌─────────┐",
    "│ │",
    "│ ● │",
    "│ │",
    "└─────────┘"),
    2: ("┌─────────┐",
    "│ ● │",
    "│ │",
    "│ ● │",
    "└─────────┘"),
    3: ("┌─────────┐",
    "│ ● │",
    "│ ● │",
    "│ ● │",
    "└─────────┘"),
    4: ("┌─────────┐",
    "│ ● ● │",
    "│ │",
    "│ ● ● │",
    "└─────────┘"),
    5: ("┌─────────┐",
    "│ ● ● │",
    "│ ● │",
    "│ ● ● │",
    "└─────────┘"),
    6: ("┌─────────┐",
    "│ ● ● │",
    "│ ● ● │",
    "│ ● ● │",
    "└─────────┘")
    }
    dice = []
    total = 0
    num_of_dice = int(input("How many dice?: "))
    for die in range(num_of_dice):
    dice.append(random.randint(1, 6))
    PRINT VERTICALLY
    for die in range(num_of_dice):
    for line in dice_art.get(dice[die]):
    print(line)
    PRINT HORIZONTALLY
    for line in range(5):
    for die in dice:
    print(dice_art.get(die)[line], end="")
    print()
    for die in dice:
    total += die
    print(f"total: {total}")

ความคิดเห็น • 77

  • @BroCodez
    @BroCodez  ปีที่แล้ว +33

    # Here are the Unicode characters I use for drawing the dice.
    # TH-cam has strange spacing, so the ASCII art looks warped in the description.
    # It should still work if you copy and paste it into PyCharm.
    # ● ┌ ─ ┐ │ └ ┘
    import random
    dice_art = {
    1: ("┌─────────┐",
    "│ │",
    "│ ● │",
    "│ │",
    "└─────────┘"),
    2: ("┌─────────┐",
    "│ ● │",
    "│ │",
    "│ ● │",
    "└─────────┘"),
    3: ("┌─────────┐",
    "│ ● │",
    "│ ● │",
    "│ ● │",
    "└─────────┘"),
    4: ("┌─────────┐",
    "│ ● ● │",
    "│ │",
    "│ ● ● │",
    "└─────────┘"),
    5: ("┌─────────┐",
    "│ ● ● │",
    "│ ● │",
    "│ ● ● │",
    "└─────────┘"),
    6: ("┌─────────┐",
    "│ ● ● │",
    "│ ● ● │",
    "│ ● ● │",
    "└─────────┘")
    }
    dice = []
    total = 0
    num_of_dice = int(input("How many dice?: "))
    for die in range(num_of_dice):
    dice.append(random.randint(1, 6))
    # PRINT VERTICALLY
    # for die in range(num_of_dice):
    # for line in dice_art.get(dice[die]):
    # print(line)
    # PRINT HORIZONTALLY
    for line in range(5):
    for die in dice:
    print(dice_art.get(die)[line], end="")
    print()
    for die in dice:
    total += die
    print(f"total: {total}")

    • @ernestdelrosario2458
      @ernestdelrosario2458 ปีที่แล้ว

      H

    • @sunrise4439
      @sunrise4439 ปีที่แล้ว

      Mr. Bro I missed u man!

    • @qber_272
      @qber_272 ปีที่แล้ว

      I confused what is this one?
      for line in dice_art.get(dice[die])
      What does the bracket do? Looking for a value of an index inside the key?

    • @kotasrinivas6810
      @kotasrinivas6810 ปีที่แล้ว

      Hi

    • @erekle99
      @erekle99 ปีที่แล้ว

      👍

  • @CodeEnthusiast78912
    @CodeEnthusiast78912 ปีที่แล้ว +20

    keep doing what you are doing, you are a hero to this community, even though i'm not interested in python rn, i'm so happy when i see you post anything.

  • @user-vc3tp8zj5s
    @user-vc3tp8zj5s ปีที่แล้ว +5

    horizontal print was blowing my mind after days without good sleep. i had to check everything by myself in pycharm and now i understand
    ty for great vid bro.

  • @thegeoman
    @thegeoman 6 หลายเดือนก่อน +1

    idk why but this in particular just feels so cool to do!

  • @estelle9819
    @estelle9819 ปีที่แล้ว

    amazing explanation of the code! tysm

  • @elevendarter112
    @elevendarter112 ปีที่แล้ว +5

    Great lesson in 10 minutes! Other youtubers would divide it into three tutorials, 30 minutes each...
    It's so easy if you know the logic behind it. Basically it's just a few simple steps, nothing new for me. However, I'd never be able to arrange these steps into this program myself. At least it would take me more than a few days, especially finding the way you printed all dice in one row.
    What's more, english isn't my native language and I've just found out that a die is a singular form of dice . And dice is plural. Cool, I learned something new in two languages at the same time :-)))

    • @mo-ab7315
      @mo-ab7315 10 หลายเดือนก่อน

      cough cough mr corey

  • @lirimbytyqi1
    @lirimbytyqi1 ปีที่แล้ว

    Great program! Thanks!

  • @Thesahilpurkaitmusic
    @Thesahilpurkaitmusic ปีที่แล้ว

    YAy bro im learning from your videos and other resources both really helpful

  • @jmm1233
    @jmm1233 8 หลายเดือนก่อน

    awesome little project for a dnd session

  • @Mizu2023
    @Mizu2023 ปีที่แล้ว +14

    Almost read the big text in the thumbnail as "Rick Roller Program" LMAO

    • @BroCodez
      @BroCodez  ปีที่แล้ว +5

      lmao

    • @az1z227
      @az1z227 ปีที่แล้ว

      I read as a Dick Roller

  • @thedeparted_one
    @thedeparted_one ปีที่แล้ว

    Bro is so awesome! Thanks.

  • @codingworld-programmerslif430
    @codingworld-programmerslif430 ปีที่แล้ว

    amazing stuff.

  • @aliashou7488
    @aliashou7488 ปีที่แล้ว

    thanks Bro! loved this video!👍

  • @tripphouse8165
    @tripphouse8165 ปีที่แล้ว

    thanks Bro! loved this video!

  • @adekunleoyero6174
    @adekunleoyero6174 8 หลายเดือนก่อน +1

    the "this is an abomination" got me

  • @theblackdragon7321
    @theblackdragon7321 ปีที่แล้ว +2

    I wonder if there is a better way to do the dice since the bottom and the top are the same for each dice. I know this is a small program in the scheme of things, but always interesting to see what can be improved upon. Thank you for all these vids that you do

    • @cubopez743
      @cubopez743 ปีที่แล้ว +2

      your dictionary could only consist of the middle 3 rows and just print the top and bottom part of the dice placing the actual dice choice in between. As for optimization idk how much faster or better memory related it would be, probably not much if at all.

  • @tee-hee9553
    @tee-hee9553 ปีที่แล้ว

    Wow so cool

  • @Beauchant
    @Beauchant ปีที่แล้ว

    Oh wow, very nice Bro.

  • @azaanahmed9562
    @azaanahmed9562 ปีที่แล้ว

    I love this

  • @muhammadsami4002
    @muhammadsami4002 ปีที่แล้ว

    Great Channel and Great Work, to easy to understand

    • @Demboys_p
      @Demboys_p ปีที่แล้ว

      how do u find python so far .

  • @_Default.
    @_Default. ปีที่แล้ว

    Can you please make a tutorial on how to make a “Key input” code like when you enter the correct key in the input it sends a console log

  • @SEBAS31077
    @SEBAS31077 ปีที่แล้ว

    wow amazing

  • @innocent_star408
    @innocent_star408 ปีที่แล้ว +2

    Make some java project ❤️‍🔥🤙🏻
    (Java builder window and net beans )both are same function ha..need to know bro✌🏻..

  • @soumoroy6747
    @soumoroy6747 6 หลายเดือนก่อน

    cool bro

  • @YouGotCAGEDyt
    @YouGotCAGEDyt ปีที่แล้ว

    Thank you bro

  • @ronaldcruz625
    @ronaldcruz625 ปีที่แล้ว

    PLEASE HELP ME! Is there anyone who have the source code of 'pseudo-random numbers' video that are formerly included in this series of videos?

  • @anonymoususer1681
    @anonymoususer1681 ปีที่แล้ว

    Would it be possible to get a Cpp version?

  • @icodeint2780
    @icodeint2780 8 หลายเดือนก่อน

    Needed that for a yahtzee games for python

  • @dezaku6612
    @dezaku6612 ปีที่แล้ว

    Ever thought of making a Go course? I think there is actually a lot of people interested

  • @rubenmatton6258
    @rubenmatton6258 ปีที่แล้ว

    Wow

  • @kristijanlazarev
    @kristijanlazarev 5 หลายเดือนก่อน

    n0ice

  • @bluebraintech4168
    @bluebraintech4168 ปีที่แล้ว +1

    thank you bro , god bless you , I'am muslim.

  • @user-vd9wf3hn5m
    @user-vd9wf3hn5m 11 หลายเดือนก่อน

    THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU

  • @sunilbarman6364
    @sunilbarman6364 10 หลายเดือนก่อน

    Hey, I was trying this code in vscode but some error is occurring. Does your code works in pycharm only that's why it might not be running in vscode or is there any other fault?

    • @user-hd8qh8lp6m
      @user-hd8qh8lp6m 9 หลายเดือนก่อน

      it runs in VScode, just have to download the python extension in the 'extensions' tab. Make sure to refresh and then it should work. Just did it on there.

  • @aijazbirsfun547
    @aijazbirsfun547 2 หลายเดือนก่อน +1

    Radhe Radhe
    Sanatan Hi Satya Hai
    Jai To All Gods & Godesses
    Jai Baba Farid Ji
    Radhaswami Ji

  • @user-zk1mh8gw7w
    @user-zk1mh8gw7w 2 หลายเดือนก่อน

    pov: you just copy and pasted the coment he game on to python AND IT WORKED

  • @kinzo9636
    @kinzo9636 ปีที่แล้ว

    is the dictonary in Python an equvilant to switch case in Java ?

    • @paraglide01
      @paraglide01 ปีที่แล้ว +1

      yes

    • @MechanicusOfficial
      @MechanicusOfficial 3 หลายเดือนก่อน

      No. The equivalent of switch in python is match instead of switch. And no break. A dictionary is a hashmap in Java.

  • @arusharamessur6856
    @arusharamessur6856 ปีที่แล้ว

    Hello, can you dobthe same dice roll game in c language, with the dice art please

  • @kubuzeer6510
    @kubuzeer6510 ปีที่แล้ว

    could you please make Entity Relationship Diagram video for mySQL? c:

  • @mohammedisarezwani
    @mohammedisarezwani 10 หลายเดือนก่อน +1

    😵‍💫😵‍💫😵‍💫😵‍💫

  • @drmicho1595
    @drmicho1595 หลายเดือนก่อน

    Why the range is 5
    The computer starts with 0 right?

  • @innocent_star408
    @innocent_star408 ปีที่แล้ว +1

    Window builder jframe and by own make some function jframe both are same functionality... Explain windows builder function about

  • @brhoom.h
    @brhoom.h ปีที่แล้ว

    I have a question : why you in the dictionary you put a tuple in the value?
    You can put a list... so is there any reason that make you decide to make it in tuple?

    • @thedeparted_one
      @thedeparted_one ปีที่แล้ว +3

      Tuples may be a bit faster, I think. Also, you don't want the values to change.

    • @brhoom.h
      @brhoom.h ปีที่แล้ว

      @@thedeparted_one Thank you

  • @ROHAN-tp7rf
    @ROHAN-tp7rf ปีที่แล้ว +3

    Sir Can You make video on Full process of App development, such as:-
    Which language is use to make Android / iOS app?
    In which software we will code this?
    How to make online games??
    🙏🙏🙏🙏

  • @arvinmistry9744
    @arvinmistry9744 ปีที่แล้ว

    Cannot see your typing in black colouer qback ground

  • @hamzazad5258
    @hamzazad5258 4 หลายเดือนก่อน

    this one is hard ngl

  • @lalamlavakumar1248
    @lalamlavakumar1248 8 หลายเดือนก่อน

    How to predict next number in game

  • @meenakshichoudhary7164
    @meenakshichoudhary7164 7 หลายเดือนก่อน

    num_dices=2
    for num in range(num_dices):
    comp_num=random.randint(1,6)
    print(comp_num)
    for i in range(5):
    print(dice_art[comp_num][i])
    here's my code, I tried it in another way.

  • @soumoroy6747
    @soumoroy6747 6 หลายเดือนก่อน

    you are my new brother bro roy

  • @mdfaisalmahamud
    @mdfaisalmahamud ปีที่แล้ว

    Javascript project video upload please

  • @JorgeLuis-ts6qp
    @JorgeLuis-ts6qp ปีที่แล้ว

    I think beginners should learn the built in sum function instead of implementing their own sum loop.

  • @rayforever
    @rayforever ปีที่แล้ว

    Good good
    now make call of duty console version

  • @bagman23
    @bagman23 ปีที่แล้ว

    first :)

  • @Aillmi
    @Aillmi 2 หลายเดือนก่อน

    print("\u25CF \u250C \u2500 \u2510 \u2502 \u2514 \u2518")

  • @dshadick
    @dshadick ปีที่แล้ว

    Greet me bro,,,

  • @avdhoot3749
    @avdhoot3749 ปีที่แล้ว

    whattttttttttttttttttttttttttttttttttttt theeeeeeeeeeeeeeeeeeeeeeeeeee fvckkkkkkkkkkkkkkkkkkkkkkkk , i dont understand bro its complexxxxxxxxxxxxxxx

  • @ivopdimitrov
    @ivopdimitrov ปีที่แล้ว

    Would be great if you post a link to GitHub repo

    • @JorgeLuis-ts6qp
      @JorgeLuis-ts6qp ปีที่แล้ว

      The code is in the video description.