ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
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}")
# 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}")
H
Mr. Bro I missed u man!
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?
Hi
👍
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.
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.
idk why but this in particular just feels so cool to do!
amazing explanation of the code! tysm
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 :-)))
cough cough mr corey
Great program! Thanks!
YAy bro im learning from your videos and other resources both really helpful
awesome little project for a dnd session
Almost read the big text in the thumbnail as "Rick Roller Program" LMAO
lmao
I read as a Dick Roller
Bro is so awesome! Thanks.
amazing stuff.
thanks Bro! loved this video!👍
thanks Bro! loved this video!
the "this is an abomination" got me
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
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.
Wow so cool
Oh wow, very nice Bro.
I love this
Great Channel and Great Work, to easy to understand
how do u find python so far .
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
wow amazing
Make some java project ❤️🔥🤙🏻
(Java builder window and net beans )both are same function ha..need to know bro✌🏻..
cool bro
Thank you bro
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?
Would it be possible to get a Cpp version?
Needed that for a yahtzee games for python
Ever thought of making a Go course? I think there is actually a lot of people interested
Wow
n0ice
thank you bro , god bless you , I'am muslim.
THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
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?
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.
Radhe Radhe
Sanatan Hi Satya Hai
Jai To All Gods & Godesses
Jai Baba Farid Ji
Radhaswami Ji
pov: you just copy and pasted the coment he game on to python AND IT WORKED
is the dictonary in Python an equvilant to switch case in Java ?
yes
No. The equivalent of switch in python is match instead of switch. And no break. A dictionary is a hashmap in Java.
Hello, can you dobthe same dice roll game in c language, with the dice art please
could you please make Entity Relationship Diagram video for mySQL? c:
😵💫😵💫😵💫😵💫
Why the range is 5
The computer starts with 0 right?
Window builder jframe and by own make some function jframe both are same functionality... Explain windows builder function about
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?
Tuples may be a bit faster, I think. Also, you don't want the values to change.
@@thedeparted_one Thank you
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??
🙏🙏🙏🙏
Cannot see your typing in black colouer qback ground
this one is hard ngl
How to predict next number in game
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.
you are my new brother bro roy
Javascript project video upload please
I think beginners should learn the built in sum function instead of implementing their own sum loop.
Good good
now make call of duty console version
first :)
nice
print("\u25CF \u250C \u2500 \u2510 \u2502 \u2514 \u2518")
Greet me bro,,,
whattttttttttttttttttttttttttttttttttttt theeeeeeeeeeeeeeeeeeeeeeeeeee fvckkkkkkkkkkkkkkkkkkkkkkkk , i dont understand bro its complexxxxxxxxxxxxxxx
Would be great if you post a link to GitHub repo
The code is in the video description.