DICE ROLLER program in Python ⚂

Поділитися
Вставка
  • Опубліковано 15 лис 2022
  • #python #tutorial #course
    Here are the Unicode characters I use for drawing the dice.
    UA-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.
    # UA-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}")

  • @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

  • @thedeparted_one
    @thedeparted_one Рік тому

    Bro is so awesome! Thanks.

  • @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