В этом учебнике по программированию на Python мы узнаем, как генерировать случайные числа и выбирать случайные данные из списков с помощью модуля random. Лично я довольно часто использую модуль random в своих уроках для генерации случайных данных. Это также может быть использовано для игр, симуляторов и множества других полезных задач. Давайте начнем. Код из этого видео можно найти по адресу:
✅ Поддержите мой канал через Patreon:
✅ Стать участником канала: ✅ Единовременный взнос через PayPal:
✅ Пожертвования в криптовалюте: Биткойн-кошелек – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3 Ethereum-кошелек – 0x151649418616068fB46C3598083817101d3bCD33 Litecoin-кошелек – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot’s Amazon Coreylists
✅ Оборудование, которое я использую, и книги, которые я рекомендую:
▶️ Вы можете найти меня на: Мой сайт –
#Питон
source
According to researches by the adsmember team
its all good and games until those fake things become real.
good tutorial though thanks!
This is awesome!! Thank you so much!!
Algorithm.
hello… I just linked this vid in my selection of Python material, thanks for your work! https://www.ohmypython.com/
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
Thank you very much exellent explaination
is it possible to put multiple functions in a variable and then print it in random.choice?
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
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
We have the same name!
Super fast! Understand everything! No bullshit around
Thanks!
its not going good
Thank u so much for this tutorial ??
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.
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
Great video! Thanks a lot!
Great job
Hey Corey, many thanks for the video, I wonder why for me the "K" for repetitions and "Weight" are not working
Thanks you
k = 10, great command, is there anything equivalent for gdscript or c#?
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?
rahmat kotta yaxshi yordam berdi
Awesome ? just straight forward to the point ??? Now, I am loyal subscriber to your channel✅
Help me to generate poker numbers
U solved the error i spent a week on in one minute true legend
When i write k= 10 it has eror
its write:
got an unexpected keyword argument 'k'
This was incredibly helpful and very simple. Thank you!!
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)
very good explanation!
very helpful thank you
With your videos! I learn python and practice my english too! You are awesome ️man!
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.
thank you so much, i really need this to make my application, Hacking Simulation
I can't say enough Thanks in every video you created on python and more!
Very good! Thanks for that
when doing random.choice(colors,k=10)
k gives error help pls
You are amazing
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
is there a way to check how many greens there are or how many reds there are?
So cool ??. Love this tutorial!
And you earned a sub. ?
print("you are the best")
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
Thanks for the recommendation I got my driver license and ssn from cardplug80 on telegram. His a verified and trusted vendor
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 ?
Thank you very much for this video 🙂 It was very helpful!
Thx Corey!
We never get same card twice.
Six be like: 09.15 and 09.16
the random.sample thing that you used. didn't do exactly what you explained us what it do.
You rock, Corey! I wish I found you earlier. That's one more amazing explanation.