Tổng Hợp

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

In this Python Programming Tutorial, we will be learning how to generate random numbers and choose random data from lists using the random module. I personally use the random module pretty often in my tutorials to generate random data. This can also be used be games, simulations, and plenty of other useful tasks. Let’s get started.

The code from this video can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –


Nguồn: https://formazione.eu.com/

Xem thêm bài viết khác: https://formazione.eu.com/tong-hop/

Tổng Hợp
[C#] Hướng dẫn viết ứng dụng tách chữ ra khỏi hình ảnh OCR
Tổng Hợp
Tổng Hợp
Hướng dẫn cài driver touchpad để tắt mở chuột trên máy tính | [iT Không Chuyên]
  • Very awesome lesson on random numbers in under 14 minutes!!!

  • How would you make sure that a certain color is not printed again?

  • Hello quick question how to make a code where if the user were to type in a certain word like "no" as the input the code will print out a random message from the "list" of words i typed in earlier?

  • All the data was written manually???

  • thanks but how do i get rid of the [ ] when it prints a random number 7:50

  • Great video with lots of informations. Thank you Corey.

  • 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 🙂

  • I made a simple rock paper scissors game using random numbers, and I want to know how to make it better. Thanks for teaching me about this.
    Rock Paper Scissors:
    import random

    rps=input("(R)ock, (P)aper, or (S)cissors?")

    if rps.lower()=="r" or rps.lower()=="rock":

    which = random.randint(1, 4)

    if which>1 and which<3:

    print("Paper. you lose")

    elif which>0 and which<2:

    print("Rock. Its a tie.")

    elif which>2 and which<4:

    print("Scissors. You win!")

    elif rps.lower()=="p" or rps.lower()=="paper":

    which2 = random.randint(1, 4)

    if which2>2 and which2<4:

    print("Scissors. you lose")

    elif which2>1 and which2<3:

    print("Paper. Its a tie.")

    elif which2>0 and which2<2:

    print("Rock. You win!")

    elif rps.lower()=="s" or rps.lower()=="scissors":

    which3 = random.randint(1, 4)

    if which3>0 and which3<2:

    print("Rock. You lose")

    elif which3>2 and which3<4:

    print("Scissors. Its a tie.")

    elif which3>1 and which3<3:

    print("Paper. You win!")


    print('Please try again and enter "Rock", "Paper", or "Scissors"')

  • Can I have django material please …. awesome material cheers..!

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

  • 7:27 random generated number code

  • thanks a lot, this help me out with my survival game! very nice and simple!

  • Can you explain please what is the role of random.seed() method ?
    I have read the documentation. But didn't find understandable.

  • Thank you, This was exactly what I was looking for.

  • im tryna make a program that randomly chooses 1 set of lists and choose something random from that list it chose instead it prints the whole list anybody able to help?

  • Hey man my Programm just closes after i Start it i was trying to make two Liste with words and thean combining theam and printing theam out ans soulutions?

  • 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

  • what can I do if it says that "random" is not defined ?

  • Thanks

  • Anyone know how I can use random numbers as coordinates for pygame? so that i can make objects move.

  • Hi could you prepare a video regarding the random.seed concept

  • Perfect! Exactly what I was looking for

  • What a dope video OMG.

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

  • great

  • Great Video! You helped me a lot. Thanks👍

  • #. Write a Python program to shuffle and print a specified list.


    import random





    why i cant define my shuffle in a new cariable?

  • Great teaching Corey!

  • Thank you! This really helped 🙂

  • great video, happy that I' ve found your channel

  • Thanks man!

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

  • Nice VIdeo

  • How would you ensure that you don't get any duplicate name/address?

  • good for random sauce generating

  • cool video !

  • 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.

  • I have some problems with the random.choices part. It says "'module' object has no attribute 'choices'". Help T-T

    Edit: nevermind I was using the wrong Python version :/

  • Hey guys I am new to python right now but I just have a small question. As he said 0:40 dad this module should not be used in security sort of things does that mean if I want to create a random password generator I should not with this module


  • thumbs up if you came here for Qazi.

  • This would be great to make an old school RPG with accuracy rolls for attacks

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

  • Thank you, best course of python I have ever found

  • 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.

  • this was exactly what I was looking for, thanks!

  • settings > playbackspeed > 0.5 speed

  • Let's Have a Quick look Video Long is 13 minute that was quicker than light

  • Hi, Corey and anyone reading this. How about seed() method? I've read about it, I tried to understand its use, but can't get to know exactly what its use is. Any help is welcome.

  • do you have an online text version of this ? so i don't have to type in your sample but just download it and learn.