В этом учебнике по программированию на Python мы узнаем, как генерировать случайные числа и выбирать случайные данные из списков с помощью модуля random. Лично я довольно часто использую модуль random в своих уроках для генерации случайных данных. Это также может быть использовано для игр, симуляторов и множества других полезных задач. Давайте начнем. Код из этого видео можно найти по адресу:

✅ Поддержите мой канал через Patreon:

✅ Стать участником канала: ✅ Единовременный взнос через PayPal:

✅ Пожертвования в криптовалюте: Биткойн-кошелек – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum-кошелек – 0x151649418616068fB46C3598083817101d3bCD33 Litecoin-кошелек – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot’s Amazon Coreylists

✅ Оборудование, которое я использую, и книги, которые я рекомендую:

▶️ Вы можете найти меня на: Мой сайт –

Мой Второй Канал – Facebook –

Твиттер –

Инстаграм –

#Питон

source
According to researches by the adsmember team

Rate us
0 0 votes
Article Rating
Subscribe
Notify of
guest
49 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Efe Uludağ
Efe Uludağ
9 months ago

its all good and games until those fake things become real.
good tutorial though thanks!

Jong Cheul Kim
Jong Cheul Kim
9 months ago

This is awesome!! Thank you so much!!

Zen Z
Zen Z
9 months ago

Algorithm.

Walter González
Walter González
9 months ago

hello… I just linked this vid in my selection of Python material, thanks for your work! https://www.ohmypython.com/

Stealth Monkey
Stealth Monkey
9 months ago

Goddamm, that was a lot of info and I understood it all.
Mighty impressed, and I'm usely super slow to understanding this kind of stuff

Sanjai S Rao
Sanjai S Rao
9 months ago

Thank you very much exellent explaination

mrsushi
mrsushi
9 months ago

is it possible to put multiple functions in a variable and then print it in random.choice?

Samuel Lawrence
Samuel Lawrence
9 months ago

Hi Corey, amazing vid. I'm completely new to python and I'm not a coder but was able to follow along and even try things on my own. Thank you.
I need your help. I'm trying to create a number generator in a sort of unconventional way. So after watching this video I came up with 2 approaches and I'm getting sort of the results that I want, but it's incomplete and I don't know where to go next.

Approach 1

col1 = [1,2,3,4,5,7,8,10,13,16]
col2 = [2,4,5,6,7,9,11,13,14,15,17,18,19,20,21,22]
col3 = [7,8,10,12,13,14,15,16,17,18,19,23,24,25,27,29,30]
col4 = [9,12,17,18,19,20,22,23,24,25,26,28,30,31,33]
col5 = [20,21,24,25,26,28,30,32,33,34,35]
b1 = [1,3,5,7,8]
b2 = [2,4,6,7,9,10,11,12]

drum1 = random.sample(col1 + col2 + col3 + col4 + col5, k=5)
drum2 = random.sample(b1 + b2, k=2)
draw1 = random.sample(drum1, k=5)
draw2 = random.sample(drum2, k=2)
main_draw = draw1 + draw2
main_draw

[30, 13, 28, 5, 30, 2, 4]

Approach 2

for num in range(4):
first = random.choice(col1)
second = random.choice(col2)
third = random.choice(col3)
forth = random.choice(col4)
fifth = random.choice(col5)
bonus1 = random.choice(b1)
bonus2 = random.choice(b2)
draw = f'{first} {second} {third} {forth} {fifth} {bonus1} {bonus2}'
print(draw)

7 6 7 23 21 5 2
13 11 14 20 30 8 9
4 6 23 17 20 5 11
5 22 23 23 20 7 11

In one I used the .choice and the other .sample.
1. My first goal is to get unique random numbers from the range of numbers I manually enter and not from say, random(1,30). I would like to give it the numbers I want it to rand between. But I want each number to be unique and as you can see from the results, that's not the case.
2. My second goal is to develop this further so that from the numbers I provide in each column as you noticed, some of the numbers in different columns are the same, I want it that way, however, I would also like it to count up, so if it chose 7 from col1 then it should start from a number greater than 7 in col2 and if it is, say 10, then it should choose one of the numbers in col3 that is greater than 10 and so on until col5.

Can you please help me?
Thank you

vaddyajay ajay
vaddyajay ajay
9 months ago

hi corey when i am importing random module after performing random operation my cmd prompt name is random is not defined could you make 1 video for that

Garfield
Garfield
9 months ago

We have the same name!

zigirs biz
zigirs biz
9 months ago

Super fast! Understand everything! No bullshit around
Thanks!

Cloakedmaple
Cloakedmaple
9 months ago

its not going good

Favour Amaah
Favour Amaah
9 months ago

Thank u so much for this tutorial 🥺💗

leo wheeler
leo wheeler
9 months ago

Im making a discord bot that is suppose to imitate a bowl you put rolled up pieces of paper into to pick at random from and throw away, after watching this video i feel halfway there, gonna look up a data base explanation video after which i feel i should be all set, thanks a bunch.

Flat Broke Productions
Flat Broke Productions
9 months ago

I'm a geek I guess but I want to create this so I can use it for solo role-playing games I create at home. Not just for dice throws but also for characters/monsters being randomly created complete with an image of the monster, number of monsters, and their details (hit points etc). Can you help me create this? Thanks

MarkNiceyard
MarkNiceyard
9 months ago

Great video! Thanks a lot!

Mechanized F1nnF1ntr33!!
Mechanized F1nnF1ntr33!!
9 months ago

Great job

Thewisesamurai
Thewisesamurai
9 months ago

Hey Corey, many thanks for the video, I wonder why for me the "K" for repetitions and "Weight" are not working

amine hero
amine hero
9 months ago

Thanks you

Your Kodi
Your Kodi
9 months ago

k = 10, great command, is there anything equivalent for gdscript or c#?

Jakub Guzowski
Jakub Guzowski
9 months ago

Czym różni się metoda randint() od randrange(). Napisz proste kody prezentujące działanie obu metod wraz z komentarzami opisującymi ich działanie?

Udalit qil
Udalit qil
9 months ago

rahmat kotta yaxshi yordam berdi

Creativity Forever
Creativity Forever
9 months ago

Awesome 😎 just straight forward to the point 👍👍💯 Now, I am loyal subscriber to your channel✅

Deepak Sharma
Deepak Sharma
9 months ago

Help me to generate poker numbers

SenpaiOfUrSensie
SenpaiOfUrSensie
9 months ago

U solved the error i spent a week on in one minute true legend

AFEE13
AFEE13
9 months ago

When i write k= 10 it has eror
its write:
got an unexpected keyword argument 'k'

sdDrums
sdDrums
9 months ago

This was incredibly helpful and very simple. Thank you!!

Toni Evangelium
Toni Evangelium
9 months ago

import random as rd

1:00 random float number between excl. (0 and 1) –> rd.random()

1:55 random float number berween excl.(1 and 10) –> rd.uniform(1, 10)
2:30 random int number between incl. [1 and 10] –> rd.randint(1, 10)
3:30 random list<int|float|string> element between incl. [1 and 10] –> rd.choice(list)
4:20 random list<int|float|string> elements-list between incl. [1 and 10] –> rd.choices(list, k=100)
5:40 rd.choices(list, weights=[8.0987,0,10,2,7,5.7,10,20,25,5.2], k=100)

hul
hul
9 months ago

very good explanation!

Fishboy23
Fishboy23
9 months ago

very helpful thank you

Lucas Caceres
Lucas Caceres
9 months ago

With your videos! I learn python and practice my english too! You are awesome ️man!

Kevin Tad-y
Kevin Tad-y
9 months ago

How do you code for a simulation of dice roll of two unique die and compare the outcome of those rolls (i.e. percentage that Die A won) in as little lines as possible? I watched the itertools video and this one to try to figure it out.

EveningR
EveningR
9 months ago

thank you so much, i really need this to make my application, Hacking Simulation

Enfield
Enfield
9 months ago

I can't say enough Thanks in every video you created on python and more!

Igor Picoli
Igor Picoli
9 months ago

Very good! Thanks for that

Zzaigon
Zzaigon
9 months ago

when doing random.choice(colors,k=10)
k gives error help pls

studiokay
studiokay
9 months ago

You are amazing

Derrick Gacheru
Derrick Gacheru
9 months ago

I'm making a guessing game where the secret number(random) should be fixed. however when i run and make a guess the secret number is randomized again. How can i fix the secret(random) number. plz help

Aadith The Gamer
Aadith The Gamer
9 months ago

is there a way to check how many greens there are or how many reds there are?

HB
HB
9 months ago

So cool 😎😎. Love this tutorial!
And you earned a sub. 👍

arnaldo ramirez
arnaldo ramirez
9 months ago

print("you are the best")

Message Realcarder74 on telegram
Message Realcarder74 on telegram
9 months ago

Thanks for Cardplug80 on Telegram for helping with me SSN/DL. His a verified vendor for your SSN/DL, cc fullz, bank logs, clone card and all sort of transfer

Message Realcarder74 on telegram
Message Realcarder74 on telegram
9 months ago

Thanks for the recommendation I got my driver license and ssn from cardplug80 on telegram. His a verified and trusted vendor

PythonicD 123
PythonicD 123
9 months ago

Amazing tutorial, off topic but it's kinda weird to enter 1,6 when I want 1 to 6 , I feel like I would be more comfortable if the last value wasn't inclusive 😅

Tymothy Lim
Tymothy Lim
9 months ago

Thank you very much for this video 🙂 It was very helpful!

S. Majid
S. Majid
9 months ago

Thx Corey!

ALVI 302
ALVI 302
9 months ago

We never get same card twice.
Six be like: 09.15 and 09.16

La Stravaganza
La Stravaganza
9 months ago

the random.sample thing that you used. didn't do exactly what you explained us what it do.

Smit Patel
Smit Patel
9 months ago

You rock, Corey! I wish I found you earlier. That's one more amazing explanation.

49
0
Would love your thoughts, please comment.x
()
x