В этом учебнике по программированию на 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ğ
26 days ago

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

Jong Cheul Kim
Jong Cheul Kim
26 days ago

This is awesome!! Thank you so much!!

Zen Z
Zen Z
26 days ago

Algorithm.

Walter González
Walter González
26 days 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
26 days 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
26 days ago

Thank you very much exellent explaination

mrsushi
mrsushi
26 days ago

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

Samuel Lawrence
Samuel Lawrence
26 days 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
26 days 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
26 days ago

We have the same name!

zigirs biz
zigirs biz
26 days ago

Super fast! Understand everything! No bullshit around
Thanks!

Cloakedmaple
Cloakedmaple
26 days ago

its not going good

Favour Amaah
Favour Amaah
26 days ago

Thank u so much for this tutorial 🥺💗

leo wheeler
leo wheeler
26 days 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
26 days 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
26 days ago

Great video! Thanks a lot!

Mechanized F1nnF1ntr33!!
Mechanized F1nnF1ntr33!!
26 days ago

Great job

Thewisesamurai
Thewisesamurai
26 days 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
26 days ago

Thanks you

Your Kodi
Your Kodi
26 days ago

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

Jakub Guzowski
Jakub Guzowski
26 days 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
26 days ago

rahmat kotta yaxshi yordam berdi

Creativity Forever
Creativity Forever
26 days ago

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

Deepak Sharma
Deepak Sharma
26 days ago

Help me to generate poker numbers

SenpaiOfUrSensie
SenpaiOfUrSensie
26 days ago

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

AFEE13
AFEE13
26 days ago

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

sdDrums
sdDrums
26 days ago

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

Toni Evangelium
Toni Evangelium
26 days 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
26 days ago

very good explanation!

Fishboy23
Fishboy23
26 days ago

very helpful thank you

Lucas Caceres
Lucas Caceres
26 days ago

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

Kevin Tad-y
Kevin Tad-y
26 days 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
26 days ago

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

Enfield
Enfield
26 days ago

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

Igor Picoli
Igor Picoli
26 days ago

Very good! Thanks for that

Zzaigon
Zzaigon
26 days ago

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

studiokay
studiokay
26 days ago

You are amazing

Derrick Gacheru
Derrick Gacheru
26 days 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
26 days ago

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

HB
HB
26 days ago

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

arnaldo ramirez
arnaldo ramirez
26 days ago

print("you are the best")

Message Realcarder74 on telegram
Message Realcarder74 on telegram
26 days 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
26 days 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
26 days 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
26 days ago

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

S. Majid
S. Majid
26 days ago

Thx Corey!

ALVI 302
ALVI 302
26 days ago

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

La Stravaganza
La Stravaganza
26 days ago

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

Smit Patel
Smit Patel
26 days 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