Python Tutorial: Generate Random Numbers and Data Using the random Module

Поделиться
HTML-код
  • Опубликовано: 3 янв 2025

Комментарии • 426

  • @LindsaySummers124
    @LindsaySummers124 6 лет назад +365

    I just learned more in 10 minutes than I have in 10 days trying to read about this on my own. Thanks! =)

    • @coreyms
      @coreyms  6 лет назад +19

      Good to hear! Glad you found it helpful

    • @coreyms
      @coreyms  6 лет назад +19

      BTW, is that Cooper's Rock in your profile picture? I used to live in Morgantown, WV and it looks very familiar

    • @mrshopd7663
      @mrshopd7663 4 года назад +1

      +

    • @oddnumber8149
      @oddnumber8149 4 года назад +2

      maybe you have dyslexia..people with dyslexia learn easily throw videos

    • @LindsaySummers124
      @LindsaySummers124 4 года назад +9

      @@coreyms haha yes! It sure is =)

  • @MrWumboloni
    @MrWumboloni 2 года назад +13

    It's been 5 years after you've made this tutorial and your work has still managed to help someone learn. Thank you Corey

  • @MyTube4Utoo
    @MyTube4Utoo 7 лет назад +107

    Amazing how Corey can teach the same concepts, but his tutorials are head and shoulders above all others!

  • @AlexJaeger716
    @AlexJaeger716 4 года назад +7

    every time I want to learn the important parts of a module without having to read its documentation, I come straight to your page. You do an incredible job Corey.. Thank you!

  • @samfiske6673
    @samfiske6673 6 лет назад +26

    Told me exactly what I needed to know, saved me from any more searching through forums. Thank you!

  • @RanZivkovic
    @RanZivkovic 5 лет назад +26

    man, I am a starter programmer, of course, python, you teach and explain so well!!! my teacher is really bad and you help a lot !!!my school doesn't do a very good job of teaching programming so u are awesome

  • @tonisun4785
    @tonisun4785 3 года назад +1

    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 element between incl. [1 and 10] --> rd.choice(list)
    4:20 random list 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)

  • @ibiamapexcel
    @ibiamapexcel 4 года назад +1

    Honestly, stumbling into your tutorials has been a great blessing to me. Your wealth of knowledge shows a versatility of experiences that is far advanced. I have learnt alot from savouring your tutorials and am really grateful for all you do.
    Thanks a lot sir.
    Kind regards from Nigeria

  • @danielazulay_9158
    @danielazulay_9158 5 лет назад +8

    You have the best tutorials ever, I mean you are making everything much easier and explaining concepts deeply and correctly, most of the tutorials out there are not doing that, thanks!!

  • @neolithian
    @neolithian 5 лет назад +13

    This is pretty cool! I was just searching for how to use random in Python. And probably this is THE BEST tutorial that exactly expressed what I want. Thanks a lot, Corey for this wonderful video!

  • @sarahalhambra2431
    @sarahalhambra2431 2 года назад

    I'm here in 2022 and this was so helpful. The explanation is clear and precise, no fluff. Thank you.

  • @tj9382
    @tj9382 Год назад +3

    Corey you are so good at teaching this stuff. I love the way you deal with each particular topic, it makes it much easier to understand. So many videos seem to jump from one topic to another. I know this stuff isn’t easy to teach but you make easier. Thanks man.

    • @easydatascience2508
      @easydatascience2508 Год назад

      see mine too. A full Python crash course tutorials step by step, sequentially, with all the source files downloadble too.

  • @vaibhavkhobragade9773
    @vaibhavkhobragade9773 5 лет назад +6

    You are my favorite python tutor and I always recommend to people your channel. Because you explain the very easiest and efficient way than spending too much time reading python documentation. Thank you @corey.

  • @AI_waaala
    @AI_waaala 5 лет назад +2

    Learnt more about Python more from ur videos than entire college year

  • @7daedalus7
    @7daedalus7 4 года назад +3

    I've been struggling my way through some classes at my community college and your videos have saved my bacon on more than one occasion. Thank you for the clear and concise content. Keep it up!

  • @indrasiswanto1161
    @indrasiswanto1161 6 лет назад

    There are lot people are excellent at programming languages, and thanks to them for willingness to teach others. However, there are only an handful that could explain and teach others. You are small number of the later category. Thank you.

  • @TheMRTIMBUK2
    @TheMRTIMBUK2 6 лет назад +3

    Never seen such an amazing teacher ever in my whole life. God Bless you .

  • @c.michaelfisher1123
    @c.michaelfisher1123 7 лет назад +5

    Holy cow! Thank you, Mr. Schafer. I was able to use this to understand how to generate a useful (and DRY!) function to handle skill rolls in my TBS Game!

  • @evansoronje2351
    @evansoronje2351 4 года назад +2

    Very awesome lesson on random numbers in under 14 minutes!!!

  • @Primeaux182
    @Primeaux182 3 года назад +2

    The random.choices part connected with the weights/probabilities is super helpful :) In another tutorial this command was not mentioned. I love it :)

  • @devilhunter1555
    @devilhunter1555 5 лет назад +1

    thank you for all the new concepts on random math functions, didn't know there was this much support for mathematical concepts

  • @kayaqueen6982
    @kayaqueen6982 2 года назад

    wow this chanel is a real deal . i learned a lot from one 10 mins videos i can't believe this

  • @mafrahamackie7074
    @mafrahamackie7074 3 года назад +1

    After so many searches, I found yours.. Thank you so much! Really simple explanation 👌👌

  • @enfieldli9296
    @enfieldli9296 3 года назад +1

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

  • @naseem5622
    @naseem5622 2 года назад +1

    bro i learned more in 10 min than in 5 days.. thanks a lot

  • @binitagusain5222
    @binitagusain5222 4 года назад +1

    This was Amazing!
    After seeing this video I was very excited to use this random function in my computer.
    Thanks for this useful information.

  • @Broncx91
    @Broncx91 7 лет назад +1

    Hey Corey,
    Thank you so much for this! I was working on a "random" number generator for a few days and was pulling aspects from multiple sources. I happened to stumble onto your video and realized that I needed to make the code into smaller pieces rather than larger ones. I was trying to have the random function that I was using do more things than it was designed to and thus kept getting an error of some sort. When I first wrote it, I couldn't get the program to loop and then if I had to roll higher than the numbers present it ran into an error due to population size so I had to find how replacement worked. Now it works. However, it has "none" twice when the program ends but that is minor. I believe it is because of my while loop and having to place return at the end in order for the loop to exit when I have do not have anymore rolls to do.
    Thank you again!

  • @ayoadeolayiwola7195
    @ayoadeolayiwola7195 4 года назад +2

    Thank you so much Corey for making time out to make all these available. You make learning python very smooth. I will definitely follow through all of these contents and practice and practice and practice. Thanks once again

  • @iabhishek1984
    @iabhishek1984 4 года назад +1

    Great teaching Corey!

  • @senpaiofursensie3675
    @senpaiofursensie3675 3 года назад

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

  • @soumyazyx
    @soumyazyx 5 лет назад +2

    Thank you Corey for your time and effort. Keep spreading the knowledge.

  • @lucascaceres3505
    @lucascaceres3505 3 года назад

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

  • @learner7273
    @learner7273 2 года назад

    Thank you, Corey. This is simple and straight to the point.

  • @pardhasaradhivasamsetty7693
    @pardhasaradhivasamsetty7693 3 года назад

    It is the one of the best tutorial that I found and best recommended for beginners. Appreicate the efforts and God bless

  • @cptmand
    @cptmand 2 года назад +1

    This is such a good channel. Really well done.

  • @GLDN06
    @GLDN06 4 года назад

    your videos help me a lot during CS.s Exam

  • @sofianenm6852
    @sofianenm6852 5 лет назад +1

    Thank you, best course of python I have ever found

  • @SHONNER
    @SHONNER 7 лет назад +2

    Cool. Thanks for this one. I been dirtying-up the code a bit to make the mailing addresses look even more randomly typed out.

  • @apollosuggs7836
    @apollosuggs7836 4 года назад +3

    This really really helped me out a lot, thanks so much for this tutorial! I'm a FAN! You rock! 💯💯💯💯

  • @halobro27
    @halobro27 3 года назад +1

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

  • @zigirsbiz910
    @zigirsbiz910 2 года назад

    Super fast! Understand everything! No bullshit around
    Thanks!

  • @Azj6dx
    @Azj6dx 6 лет назад +2

    Thank you!! I'm teaching myself to code and I've been searching everywhere for the 'random.choice' function!! 😂 I can now receive a value from a list at random!

  • @cyberbooth1585
    @cyberbooth1585 4 года назад +1

    Great video with lots of informations. Thank you Corey.

  • @cochogod
    @cochogod Год назад

    Very clear and straightforward, +1

  • @dev4life
    @dev4life 6 лет назад

    Big bro, your teaching style is just awesome, after Bucky from the new Boston, you are my favorite programming teacher... God bless you

  • @bratwurst8931
    @bratwurst8931 5 лет назад +3

    this was exactly what I was looking for, thanks!

  • @smitpatel1358
    @smitpatel1358 3 года назад

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

  • @ExcelTutorials1
    @ExcelTutorials1 Год назад

    Dude, this is awesome. Very helpful and well explained! Thank you!!!

  • @skeoals
    @skeoals Год назад +1

    this was simply amazing. thank you!!

  • @s.baskaravishnu22
    @s.baskaravishnu22 5 лет назад +1

    your videos are excellent. Your videos are very much useful to me, Many thanks for that. My warm regards to you.

  • @fredrickadhinga1609
    @fredrickadhinga1609 5 лет назад +5

    I loved this man...can you do another one explaining how to link the random data to a user's input to consider a lucky winner.

  • @akashnaveen7475
    @akashnaveen7475 3 года назад

    amazing video brro you just clear all my doubts soo easily.......thank you sooo much

  • @reemabdella4443
    @reemabdella4443 Год назад +1

    You are doing really great thank you so much!

  • @IgorPicoli
    @IgorPicoli 3 года назад

    Very good! Thanks for that

  • @HypnosisBear
    @HypnosisBear 3 года назад +1

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

  • @Mariam-gd4to
    @Mariam-gd4to 6 лет назад +2

    Thanks a lot, this tutorial is so clear and helpful

  • @SelmanAy
    @SelmanAy 7 лет назад +5

    Hellooo! , probably Im the first one and opened sublime text immediately to do what you are gonna teach :) ty from now ^^

  • @saidzbita6073
    @saidzbita6073 5 лет назад +2

    Thank you so much for this awesome video, it gives me more idea about the random module. thank you again.

  • @GHOST-qg1em
    @GHOST-qg1em 5 лет назад +2

    I learned a lot in this video, thank you so much for this video. :)

  • @lavo8404
    @lavo8404 3 года назад +1

    Omg thanks. I have learnt thanks to you

  • @garimajain474
    @garimajain474 Год назад

    No words to say thankuu... Awesome content🙇🙇🙇🙇🙇🙇🙇🙇🙇🙇🙇🙇🙇🙇

  • @shuklanikhil62
    @shuklanikhil62 2 года назад

    Nice & Easy Concepts ,Thanks for the informative video

  • @kennethha8173
    @kennethha8173 3 года назад +1

    Omg , yes I finally found what I was looking for , thanks a lot

  • @choporo2005
    @choporo2005 4 года назад +1

    Great Video! You helped me a lot. Thanks👍

  • @teslan2009
    @teslan2009 3 года назад

    very precise and super insightful

  • @conqueror346
    @conqueror346 2 года назад +1

    Nice explanation 👍👍

  • @MrSeinfeldFan2
    @MrSeinfeldFan2 4 года назад

    Oh boy, I needed this video! THANKS.

  • @balintmucsanyi6322
    @balintmucsanyi6322 4 года назад

    great video, happy that I' ve found your channel

  • @eddw123
    @eddw123 3 года назад

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

  • @gameboardgames
    @gameboardgames 2 года назад

    This was ribeye quality, thanks!

  • @caydanphoenix9067
    @caydanphoenix9067 4 года назад

    Example🔥...loved this idea🔥

  • @ZdenoMucina
    @ZdenoMucina 5 лет назад +1

    very clear explanation :) thank you :)

  • @jongcheulkim7284
    @jongcheulkim7284 2 года назад

    This is awesome!! Thank you so much!!

  • @nadeemsuleman4326
    @nadeemsuleman4326 4 года назад

    Thank you for enabling to generate data for practicing

  • @xxalienxxyt9337
    @xxalienxxyt9337 5 лет назад +1

    I've read about random functions in Python all the time but from your video the commands got burned in my brain. I learned ay more from this.

  • @edwinaldrin6820
    @edwinaldrin6820 3 года назад

    good one , easily understood
    thanks man

  • @MarkoBrainz
    @MarkoBrainz 4 года назад +1

    Thank you very much, sir! You helped me a lot! You gave me a few steps to my dream to be a programmer :0

  • @erfanahmadi2569
    @erfanahmadi2569 4 года назад

    I really needed this. Thank you so much

  • @TFB2K-baubau
    @TFB2K-baubau Год назад

    that actually helped a lot man.
    thanks

  • @vaibhavkrkm
    @vaibhavkrkm 4 года назад +2

    Nice tutorial 👍🤗 u are my one of the most favorite teachers whom I came across :)
    Anyways, I think we can leave range without list function also right, cuz it already returns a list of the given range..🤔
    Love from India :)

  • @MemoThePanda
    @MemoThePanda 2 года назад

    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

  • @foxygaming557
    @foxygaming557 5 лет назад +2

    I’m making a blackjack game using this thank you for helping

  • @koodauskanava9096
    @koodauskanava9096 7 лет назад +1

    Thanks, very useful information. Really like the weight parameter and sample method, didn't knew it before :)

  • @Mister___HACKER
    @Mister___HACKER Год назад

    Thanks bro it helped me lot as a beginner

  • @susmitamazumder8390
    @susmitamazumder8390 5 лет назад

    I have learned a lot from your video. you are amazing. you are simly the best.and you have really nice voice. Its so cool!!!!

  • @jasonrobinette4486
    @jasonrobinette4486 7 лет назад +1

    thanks Corey your videos are great!

  • @redictedgonebad
    @redictedgonebad 2 года назад

    This was AWESOME!!!

  • @tymothylim6550
    @tymothylim6550 3 года назад

    Thank you very much for this video :) It was very helpful!

  • @raghavnegi713
    @raghavnegi713 4 года назад

    Thanks a lot. This help me fixed the bug in my game.

  • @aaliyahjardien
    @aaliyahjardien 2 года назад

    This was very useful, thank you 😊

  • @vijayg3248
    @vijayg3248 Год назад

    Excellent work keep on work like this broo❤😊

  • @Potato-ff9ms
    @Potato-ff9ms 3 года назад

    you can get integers in the uniform method by placing and "int(random.uniform(1, 10))"

  • @Endlessvoidsutidos
    @Endlessvoidsutidos 5 лет назад +2

    another awesome vid you should write a book how to program the
    Corey Schafer way best seller in the tech industry fo sure

  • @RDhiru001
    @RDhiru001 5 лет назад +3

    thank u sir ,for such a amazing video

  • @Potato-ff9ms
    @Potato-ff9ms 3 года назад

    to get better list you can do:
    list {
    'random1',
    "ramdon2,"
    }
    still love this video, so ill probably sub

  • @phisherm64vcx67
    @phisherm64vcx67 4 года назад

    You're Legend ..Keep Going

  • @bam.polyglot
    @bam.polyglot 4 года назад +1

    I got to say: Thank you a lot! You got one more subscriber too.

    • @xfire3778
      @xfire3778 4 года назад

      Do you know what a subscript is

    • @bam.polyglot
      @bam.polyglot 4 года назад

      @@xfire3778Oh, I am not a native speaker LOL I think it should be subscriber, right?

    • @xfire3778
      @xfire3778 4 года назад

      Elber Almeida yeah 👍

  • @waltermorales9849
    @waltermorales9849 6 лет назад +1

    great video buddy!

  • @mncedisinelsonmlumbi8003
    @mncedisinelsonmlumbi8003 4 года назад +1

    What a dope video OMG.

  • @TorIvanBoine
    @TorIvanBoine 6 лет назад +1

    awesome. that "for num in range ..." section helped me with the problem I had.