Generate random numbers in Python 🎲

preview_player
Показать описание
#python #tutorial #course

Python random module tutorial example explained

00:00:00 random module
00:04:32 number guessing game

import random

low = 1
high = 20
options = ['Rock', 'Paper', ‘Scissors’]
cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']

Рекомендации по теме
Комментарии
Автор

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")

BroCodez
Автор

Thank you for your help, You’re better than my Professors!

jeshmex
Автор

First python game I've ever made. Feel super pround of myself lmfao. Thanks for the video boss!

alext
Автор

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!!

meetmakvana
Автор

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☺️☺️

sakshamkapoor
Автор

Thanks so much. Already did a personal version with some extra features.

sarapiqui_educational
Автор

Iteresting that you practically explained binary search while solving the game :)

bankayxy
Автор

Thank you for Help! While I ran my code the first time I used the same guesses because I had also the 9 :)

MaxMax-mkji
Автор

Hello. Please complement your Java course with Functional Interfaces. Predicate, Consumer, Supplier.

brunogreco
Автор

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!

jadotati
Автор

Hello. Please course of Spring Security. Docker and Kubernetes

brunogreco
Автор

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
Автор

I wonder if i can make this code something similar to a input-spamming program. I guess i should find out

DefinedCmajor
Автор

How to you minimal your run terminal, I mean green color output of you code . How do you do that?

emonthetitobalfour
Автор

bro! you should have discord discussion. i would love to join yours

KoKo_Bunch
Автор

It took me so long to figure out i just had to make an indent for while True 😭😭

Degasinsano
Автор

What IDE are you using @BroCode please reply 🙏🙏🙏🙏

VyCorr
Автор

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?😃

Uberdurden
Автор

Can anyone explain why my idle don't look like this ?

binoyendupoddar
Автор

Looks so simple when I watching your videos but when I want to do my

ssigitas