Generate random numbers in Python 🎲

  Рет қаралды 78,926

Bro Code

Bro Code

Күн бұрын

Пікірлер: 75
@BroCodez
@BroCodez 2 жыл бұрын
import random low = 1 high = 100 options = ("Rock", "Paper", "Scissors") cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] # number = random.random() # number = random.randint(low, high) # choice = random.choice(options) # random.shuffle(cards) # -------------- NUMBER GUESSING GAME -------------- import random low = 1 high = 100 guesses = 0 number = random.randint(low, high) while True: guess = int(input(f"Enter a number between ({low} - {high}): ")) guesses += 1 if guess < number: print(f"{guess} is too low") elif guess > number: print(f"{guess} is too high") else: print(f"{guess} is correct!") break print(f"This round took you {guesses} guesses")
@Hindu-hai_hum168
@Hindu-hai_hum168 Жыл бұрын
Sir please number send me
@mirzaahmadsodiqov2457
@mirzaahmadsodiqov2457 Жыл бұрын
Hello Bro, I tried to write the code. I don't know exactly why but when I just copied your above mentioned code my ''Pycharm'' gave me the next: Traceback (most recent call last): File "C:\Users\mirza\PycharmProjects\pythonProject\a.py", line 1, in import random File "C:\Users\mirza\PycharmProjects\pythonProject andom.py", line 4, in random.randint(x, y) ^^^^^^^^^^^^^^ AttributeError: partially initialized module 'random' has no attribute 'randint' (most likely due to a circular import)
@chug_jug200
@chug_jug200 Жыл бұрын
if the file name is random.py that may be the problem. Rename ur file and it will fix it@@mirzaahmadsodiqov2457
@caseywong8565
@caseywong8565 11 ай бұрын
Hi Bro... a question about this following syntax ----> # random.shuffle(cards) Why does this work? # random.shuffle(cards) #print(cards) and why does this not work?: card = random.shuffle(cards) print(card) the latter seems to follow the logic in your previous examples in this video. What am I missing?
@jeshmex
@jeshmex 2 жыл бұрын
Thank you for your help, You’re better than my Professors!
@alex1311t
@alex1311t Жыл бұрын
First python game I've ever made. Feel super pround of myself lmfao. Thanks for the video boss!
@sakshamkapoor491
@sakshamkapoor491 2 жыл бұрын
Bcoz of you I had learn the coding and develop my skills and due to that i am able to get admission in IIT all bcoz of you thank you for your hardwork and dedication☺️☺️
@VAIBHAVMALHOTRA19
@VAIBHAVMALHOTRA19 9 ай бұрын
Best of luck for your journey. Btw which IIT?
@orewa_AB
@orewa_AB 9 ай бұрын
never knew there is a coding test to get admission into IIT , I thought they only test your PCM knowledge to give you admission for CSE
@Gargantuan_Inferno
@Gargantuan_Inferno 5 ай бұрын
Bro stop capping pretty sure you are in tier 3-4 college or in school...never has IIT asked anything CS related lmfao the audacity
@Poulumi4680
@Poulumi4680 2 ай бұрын
Iit is admitted by jee exam so how the python course help it's help to get job and learn skill?
@filippobargagna
@filippobargagna Жыл бұрын
Iteresting that you practically explained binary search while solving the game :)
@meetmakvana7332
@meetmakvana7332 Жыл бұрын
Thank you so much Bro Code You saved my Computer Science in School You have helped me improve significantly I couldn't be more grateful of you!!
@TwitchPrimer
@TwitchPrimer 3 ай бұрын
The random number guessing game is so cool!
@sarapiqui_educational
@sarapiqui_educational Жыл бұрын
Thanks so much. Already did a personal version with some extra features.
@m8nfan975
@m8nfan975 2 жыл бұрын
❤ from India bro 🥰🥰
@ssigitas69
@ssigitas69 Жыл бұрын
Looks so simple when I watching your videos but when I want to do my self......
@freaknation1314
@freaknation1314 7 ай бұрын
Hurt your brain by giving deep ideas and concepts ...and u become unique legend
@marilynlucero9363
@marilynlucero9363 6 ай бұрын
Yeah exactly this... for already a few years, have had to randomize a d&d-esque game I have with my friends with the only major issue being that figuring out exactly what's been rolled takes a short time... I just need something coded so I can get a result with 1 click of a button. Trying to watch this, DLed Python, didn't get the screen I see, tried it with Visual (something) Code, didn't get anything either and then Microsoft wanting me to give Python language while I've already been typing that. I am left even more confused right now, tried with both JavaScript and Python. Having all the creativity to make something for my friends and I to enjoy without any of the skills besides typing on a keyboard like a rabid ape to actually pull it off efficiently.
@praveenkumarmj2387
@praveenkumarmj2387 2 жыл бұрын
Thank you brother.
@aahana19
@aahana19 14 күн бұрын
from Nepal!!
@ComputerAddict23
@ComputerAddict23 6 ай бұрын
It took me so long to figure out i just had to make an indent for while True 😭😭
@ßavs
@ßavs 4 ай бұрын
thanks from Nepal ❤
@aimentality
@aimentality 4 ай бұрын
Thanks a lot ❤
@Marcapoc
@Marcapoc 7 күн бұрын
Im still learing but i was wondering if you can add probabilities to the options like i have a tuple of options and i want to make certain options with lower probability to be chosen
@hritiktheopgamer4122
@hritiktheopgamer4122 2 жыл бұрын
thank for info
@godofyoshy
@godofyoshy 23 күн бұрын
Since sets are unordered, wouldn't it be okay to put the sequence of cards inside a set? we wouldn't have to use the (random.shuffle) function.
@emonthetitobalfour6741
@emonthetitobalfour6741 Жыл бұрын
How to you minimal your run terminal, I mean green color output of you code . How do you do that?
@ComputerAddict23
@ComputerAddict23 6 ай бұрын
Just put \033[92m before every print Example: print("\033[92mJohn")
@dominikalatusek7686
@dominikalatusek7686 Жыл бұрын
Thank You BroCode!
@ThuậnPhạm-d8o
@ThuậnPhạm-d8o 2 күн бұрын
name = input("Who are you?") print(f"This is {name} - from Việt Nam with love")
@extendedsomeone
@extendedsomeone 2 ай бұрын
#GeneraterandomnumbersinPython : import random print("Hi, I'm a Python Number Guessing Game 🎲.") low = 1 high = 100 guesses = 0 number = random.randint(low, high) while True: guess = int(input(f"Enter a number between ({low} - {high}): ")) guesses += 1 if guess < number: print(f"{guess} is too low") elif guess > number: print(f"{guess} is too high") else: print(f"{guess} is correct!") break print(f"This round took you {guesses} guesses")
@Amit-m1h
@Amit-m1h Жыл бұрын
Thank you bro
@MaxMax-mk7ji
@MaxMax-mk7ji Жыл бұрын
Thank you for Help! While I ran my code the first time I used the same guesses because I had also the 9 :)
@FerintoshFarmsPhotography
@FerintoshFarmsPhotography Жыл бұрын
I thought about not liking the video because it was at 669, so lets get it to 6669 bros.
@NikolasManoudakis
@NikolasManoudakis 6 ай бұрын
We did NOT get it to 6669 😭
@bong_14k
@bong_14k 2 жыл бұрын
the bast brother
@GuiROYER
@GuiROYER 2 жыл бұрын
tmj bro. TYS
@jadotati7641
@jadotati7641 2 жыл бұрын
Hi bro code , I habe a question about java swing. In your last java swing video (ping pong game) you used the "Rectangle" class. example: "Public class paddle extends Rectangle {" What does " extends Rectangle" mean ? I searched a lot but nobody talked about this on youtube or google before!
@CatChrist
@CatChrist 2 жыл бұрын
not sure if someone has answered this for you already or not, but that is how inheritance from a class works in Java! So in the example you give, Rectangle is the parent class to the child class Paddle. This gives Paddle (assumedly a new user created Class, I haven't seen his video) all the same attributes as the Rectangle included in the package he is using. In python it would look like this: class Paddle(Rectangle): QUICK EDIT -> tldr: Rectangle is a class that Paddle inherits from
@VyCorr
@VyCorr Жыл бұрын
What IDE are you using @BroCode please reply 🙏🙏🙏🙏
@davidhirschhorn2960
@davidhirschhorn2960 Жыл бұрын
He is using PyCharm, community (free) version. The first video in the series has him installing it.
@MeSoyCapitan
@MeSoyCapitan 2 жыл бұрын
How would you weight options, like you were using a loaded dice? For example if you had a luck stat, it could increase your chance of a 6 or a face card.
@MeSoyCapitan
@MeSoyCapitan 2 жыл бұрын
Maybe this could make for an enticing thumbnail / video title.
@SchoderIB
@SchoderIB 6 ай бұрын
@@MeSoyCapitan haha
@MiBaLinuxTech
@MiBaLinuxTech Жыл бұрын
Hi bro look at this: Enter a number between (1 - 100): 95 95 is too high Enter a number between (1 - 100): 93 93 is too low Enter a number between (1 - 100): 94 94 is too low Enter a number between (1 - 100): / 95 is tigh, 94 is to low What is happen?
@Poulumi4680
@Poulumi4680 2 ай бұрын
Bro code like code with harry these people are awesome ❤❤❤❤❤❤❤❤❤❤❤❤❤❤freeand relevant content
@brunogreco290
@brunogreco290 2 жыл бұрын
Hello. Please course of Spring Security. Docker and Kubernetes
@brunogreco290
@brunogreco290 2 жыл бұрын
Hello. Please complement your Java course with Functional Interfaces. Predicate, Consumer, Supplier.
@Priceygames
@Priceygames Жыл бұрын
I am now convinced python is better than c++. C++ is so long to code while python only needs 1 line 😮
@VAIBHAVMALHOTRA19
@VAIBHAVMALHOTRA19 9 ай бұрын
Every language is better in its own way. Python is an interpreter language whereas C++ is a compiler language. Both languages have different uses for example python is mainly used in data science whereas C++ is used for developing OS or video games.
@ramkoirala3457
@ramkoirala3457 8 ай бұрын
🎲
@DefinedCmajor
@DefinedCmajor Жыл бұрын
I wonder if i can make this code something similar to a input-spamming program. I guess i should find out
@Wrennythegoat
@Wrennythegoat 7 ай бұрын
whats the app your running python in ?
@caglakazanc6837
@caglakazanc6837 7 ай бұрын
pycharm
@TopWantedPlayers
@TopWantedPlayers 5 ай бұрын
Legend​@@caglakazanc6837
@binoyendupoddar2513
@binoyendupoddar2513 6 ай бұрын
Can anyone explain why my idle don't look like this ?
@KoKo_Bunch
@KoKo_Bunch 2 жыл бұрын
bro! you should have discord discussion. i would love to join yours
@gemanimeku912
@gemanimeku912 Жыл бұрын
can u teach me, how to generate random number with letter, like a number plate of car "B 3654 ZA"
@atrantech11
@atrantech11 Жыл бұрын
I'd put your choices into an list, then call .choice(nameOfList) on it through while loop with the maximum number of characters you want in your number plate
@riverkey79
@riverkey79 2 жыл бұрын
Does anybody know how to remove the square brackets, speech marks, commas and spacing from the output? So if you were shuffling the cards, the output just read - 31JA957K etc?
@siyamfakur1263
@siyamfakur1263 2 жыл бұрын
import random cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] ans = "" for i in cards: ans = ans+i print(ans)
@cvhjska
@cvhjska 2 жыл бұрын
a hint of binary search🤔
@sakshamkapoor491
@sakshamkapoor491 2 жыл бұрын
Hi bro
@creeprshh3812
@creeprshh3812 Жыл бұрын
🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍
@Uberdurden
@Uberdurden Жыл бұрын
import random low=1 highest=50 guesses=0 number=random.randint(low,highest) while True: texminler=int(input(f'Guess the number between {low} - {highest}: ')) if number==12: print('you doing well budy!') break elif number==24: print('your soo good!') break elif number==48: print('holyyy!!!') break else: print('another time budy !') i think this is much better huh?😃
@popularsun
@popularsun 2 жыл бұрын
yo!
@laopichthyrith9
@laopichthyrith9 2 жыл бұрын
Second
@rfatefehelvacoglu335
@rfatefehelvacoglu335 Жыл бұрын
i lost 03:20
@riyal_dulal
@riyal_dulal 6 ай бұрын
random module error
@Zortdedifare
@Zortdedifare 2 жыл бұрын
1 praying
@insanesam530
@insanesam530 Жыл бұрын
returns none ):
@unholycrusader69
@unholycrusader69 2 жыл бұрын
Cryptography 4 dummies
Let's code a Python NUMBER GUESSING GAME! 🔢
8:20
Bro Code
Рет қаралды 14 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Python concession stand program 🍿
8:10
Bro Code
Рет қаралды 52 М.
random numbers in python
5:55
computingmrh
Рет қаралды 79 М.
Pseudo-Random Number Generator From Scratch in Python
15:46
NeuralNine
Рет қаралды 9 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 459 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 267 М.
Functions in Python are easy 📞
10:38
Bro Code
Рет қаралды 644 М.
How programmers flex on each other
6:20
Fireship
Рет қаралды 2,6 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Making a Game in Python with No Experience
5:57
Goodgis
Рет қаралды 1,8 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН