DICE ROLLER program in Python ⚂

  Рет қаралды 66,475

Bro Code

Bro Code

Күн бұрын

#python #tutorial #course
Here are the Unicode characters I use for drawing the dice.
KZbin 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}")

Пікірлер: 79
@BroCodez
@BroCodez Жыл бұрын
# Here are the Unicode characters I use for drawing the dice. # KZbin 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 Жыл бұрын
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.
@Ігорка-к8е
@Ігорка-к8е Жыл бұрын
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.
@elevendarter112
@elevendarter112 Жыл бұрын
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 Жыл бұрын
cough cough mr corey
@thegeoman
@thegeoman 8 ай бұрын
idk why but this in particular just feels so cool to do!
@RSOFT92
@RSOFT92 Күн бұрын
For me as a python beginner (started with Manim just yesterday) it feels like the first time i programmed with BlitzBasic (a Basic IDE) over 15 Years ago. @Bro Code Very good Tutorial! You just got a new Subscriber! 🙂
@Mizu2023
@Mizu2023 Жыл бұрын
Almost read the big text in the thumbnail as "Rick Roller Program" LMAO
@BroCodez
@BroCodez Жыл бұрын
lmao
@az1z227
@az1z227 Жыл бұрын
I read as a Dick Roller
@theblackdragon7321
@theblackdragon7321 Жыл бұрын
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 Жыл бұрын
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.
@jmm1233
@jmm1233 10 ай бұрын
awesome little project for a dnd session
@Thesahilpurkaitmusic
@Thesahilpurkaitmusic Жыл бұрын
YAy bro im learning from your videos and other resources both really helpful
@syedzubyl
@syedzubyl Жыл бұрын
Make some java project ❤️‍🔥🤙🏻 (Java builder window and net beans )both are same function ha..need to know bro✌🏻..
@adekunleoyero6174
@adekunleoyero6174 11 ай бұрын
the "this is an abomination" got me
@estelle9819
@estelle9819 Жыл бұрын
amazing explanation of the code! tysm
@aijazbirsfun547
@aijazbirsfun547 5 ай бұрын
Radhe Radhe Sanatan Hi Satya Hai Jai To All Gods & Godesses Jai Baba Farid Ji Radhaswami Ji
@muhammadsami4002
@muhammadsami4002 Жыл бұрын
Great Channel and Great Work, to easy to understand
@Demboys_p
@Demboys_p Жыл бұрын
how do u find python so far .
@thedeparted_one
@thedeparted_one Жыл бұрын
Bro is so awesome! Thanks.
@EclipseRoblx
@EclipseRoblx Жыл бұрын
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
@lirimbytyqi1
@lirimbytyqi1 Жыл бұрын
Great program! Thanks!
@tee-hee9553
@tee-hee9553 Жыл бұрын
Wow so cool
@Beauchant
@Beauchant Жыл бұрын
Oh wow, very nice Bro.
@bluebraintech4168
@bluebraintech4168 Жыл бұрын
thank you bro , god bless you , I'am muslim.
@SEBAS31077
@SEBAS31077 Жыл бұрын
wow amazing
@aliashou7488
@aliashou7488 Жыл бұрын
thanks Bro! loved this video!👍
@tripphouse8165
@tripphouse8165 Жыл бұрын
thanks Bro! loved this video!
@codingworld-programmerslif430
@codingworld-programmerslif430 Жыл бұрын
amazing stuff.
@azaanahmed9562
@azaanahmed9562 Жыл бұрын
I love this
@KrathEugine
@KrathEugine 5 ай бұрын
pov: you just copy and pasted the coment he game on to python AND IT WORKED
@rubenmatton6258
@rubenmatton6258 Жыл бұрын
Wow
@icodeint2780
@icodeint2780 10 ай бұрын
Needed that for a yahtzee games for python
@noelaiman-l7s
@noelaiman-l7s Жыл бұрын
THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
@mohammedisarezwani
@mohammedisarezwani Жыл бұрын
😵‍💫😵‍💫😵‍💫😵‍💫
@syedzubyl
@syedzubyl Жыл бұрын
Window builder jframe and by own make some function jframe both are same functionality... Explain windows builder function about
@meenakshichoudhary7164
@meenakshichoudhary7164 9 ай бұрын
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 9 ай бұрын
cool bro
@YouGotCAGEDyt
@YouGotCAGEDyt Жыл бұрын
Thank you bro
@kristijanlazarev
@kristijanlazarev 8 ай бұрын
n0ice
@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 Жыл бұрын
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
@drmicho1595
@drmicho1595 3 ай бұрын
Why the range is 5 The computer starts with 0 right?
@sunilbarman6364
@sunilbarman6364 Жыл бұрын
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?
@McCoysLawnCareServices
@McCoysLawnCareServices 11 ай бұрын
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.
@kubuzeer6510
@kubuzeer6510 Жыл бұрын
could you please make Entity Relationship Diagram video for mySQL? c:
@JorgeLuis-ts6qp
@JorgeLuis-ts6qp Жыл бұрын
I think beginners should learn the built in sum function instead of implementing their own sum loop.
@anonymoususer1681
@anonymoususer1681 Жыл бұрын
Would it be possible to get a Cpp version?
@dezaku6612
@dezaku6612 Жыл бұрын
Ever thought of making a Go course? I think there is actually a lot of people interested
@arusharamessur6856
@arusharamessur6856 Жыл бұрын
Hello, can you dobthe same dice roll game in c language, with the dice art please
@kinzo9636
@kinzo9636 Жыл бұрын
is the dictonary in Python an equvilant to switch case in Java ?
@paraglide01
@paraglide01 Жыл бұрын
yes
@MechanicusOfficial
@MechanicusOfficial 6 ай бұрын
No. The equivalent of switch in python is match instead of switch. And no break. A dictionary is a hashmap in Java.
@arvinmistry9744
@arvinmistry9744 Жыл бұрын
Cannot see your typing in black colouer qback ground
@hamzazad5258
@hamzazad5258 7 ай бұрын
this one is hard ngl
@soumoroy6747
@soumoroy6747 9 ай бұрын
you are my new brother bro roy
@rayforever
@rayforever Жыл бұрын
Good good now make call of duty console version
@mdfaisalmahamud
@mdfaisalmahamud Жыл бұрын
Javascript project video upload please
@lalamlavakumar1248
@lalamlavakumar1248 11 ай бұрын
How to predict next number in game
@ronguitar23
@ronguitar23 Жыл бұрын
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?
@bagman23
@bagman23 Жыл бұрын
first :)
@BroCodez
@BroCodez Жыл бұрын
nice
@ECHOISBACK
@ECHOISBACK Ай бұрын
@@BroCodez VERY NICE
@_ravissement
@_ravissement Ай бұрын
@@BroCodez VERY VERY NICE
@Aillmi
@Aillmi 4 ай бұрын
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.
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 80 М.
Encryption program in Python 🔐
8:41
Bro Code
Рет қаралды 124 М.
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 85 МЛН
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 21 МЛН
Javascript - Part 11 - Callback Hell
6:28
தழல் மென்பொருள் (Thazhal Software)
Рет қаралды 644
Let's code a SNAKE GAME in python! 🐍
33:06
Bro Code
Рет қаралды 639 М.
If Your Tech Job is Comfortable, You're in Danger
20:57
Thriving Technologist
Рет қаралды 23 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 384 М.
Why Tesla is winning ? - The Tesla killers that came and went!
20:56
Let's code a beginner's Python BANK PROGRAM 💰
15:01
Bro Code
Рет қаралды 206 М.
ROCK PAPER SCISSORS game in Python 🗿
9:29
Bro Code
Рет қаралды 133 М.