Random number generator in Python

Поділитися
Вставка
  • Опубліковано 1 лют 2025
  • In this video, you will learn how to generate random numbers in python using the random module.
    We will understand each method in detail with examples.
    source code : theprogramming...
    GIT : github.com/The...
    Random module - docs.python.or...
    Random() - docs.python.or...
    Randint() - docs.python.or...
    Randrange() - docs.python.or...
    Uniform() - docs.python.or...
    Sample() - docs.python.or...
    Shuffle() - docs.python.or...
    Choice() - docs.python.or...
    Python tutorial - docs.python.or...
    In this video you will learn:
    how to generate random numbers in python
    random module in python
    range function in python
    importing random module in python
    python built in function
    Random method
    Randint method
    Randrange method
    Uniform method
    Sample method
    Shuffle method
    Choice method
    Want to learn more from me?
    Python examples complete Playlist :
    • python program for str...
    Java examples complete Playlist :
    • Java Factorial Program
    #PythonProgramForRandomNumber
    #PythonTutorialForBeginners
    #PythonTutorial
    #RandomNumberGeneratorInPython
    #RandomNumberProgramInPython
    #PythonExamples
    #RandomNumber
    Subscribe to my other channel for random videos:
    IndianBox : / @indianbox1736
    Follow us on:
    Facebook : / theprogrammingportal
    Instagram : / theprogrammingportal
    Support:
    Patreon : / theprogrammingportal
    Keep Coding!

КОМЕНТАРІ • 52

  • @fasty93
    @fasty93 2 роки тому +4

    I am learning python and I wanted to create a variable input that is random, and it works! all thanks to you!

  • @soloxballer
    @soloxballer 3 роки тому +8

    Thank you man I was looking for the random float and you were the only guy who had it

  • @NateCody
    @NateCody 2 роки тому +12

    Thanks so much! I needed this for a project I’ve been working on

  • @melissaleigh8019
    @melissaleigh8019 10 місяців тому

    God bless you, passing on your knowledge to many people.

  • @josh-lut769
    @josh-lut769 4 місяці тому

    clear, concise but very usefull !! i'm very gratful

  • @al-hashim8038
    @al-hashim8038 3 місяці тому

    Good explanation 👍

  • @shqckwave8085
    @shqckwave8085 2 роки тому

    Thanks so much I really needed randrange and this is the first one that helped me find out.

  • @Tooobiasss0
    @Tooobiasss0 6 місяців тому +1

    great video, helped a lot!

  • @AlexanderCortes210486
    @AlexanderCortes210486 Рік тому +1

    👍 very nice explanation

  • @AlekWCcom
    @AlekWCcom Рік тому

    thanks for the simple turturial. it is very usefull and eesy to understand

  • @nov3m472
    @nov3m472 Рік тому +10

    in the beginning i understood "Hi there, iam russian and welcome to programming putin" 🗿

  • @tristanheck2209
    @tristanheck2209 3 роки тому +1

    thanks.
    I was looking for random float between given range 3:35.

    • @TheProgrammingPortal
      @TheProgrammingPortal  3 роки тому +1

      Glad it helped you.

    • @tristanheck2209
      @tristanheck2209 3 роки тому

      @@TheProgrammingPortal yeah, you explained it well.
      I'm using it to spawn obstacles on random positions in my prototype. will propably use it much more in the future

  • @voscapattern
    @voscapattern 8 місяців тому

    thanks much

  • @noguy31
    @noguy31 9 місяців тому

    how do you get to do the pop up of the arguments you can input when you type

  • @karenrodrigues5173
    @karenrodrigues5173 3 роки тому +2

    Is there a way to generate ids without importing the random module?

  • @infotricks2589
    @infotricks2589 2 роки тому

    It's very interesting 🥰🥰

  • @malvis8737
    @malvis8737 2 роки тому +1

    how do I create a random number in a normal distribution with standard deviation and media ?

  • @aaryankumar7395
    @aaryankumar7395 2 роки тому

    how can we store maximum value of random function in a variable like i want to store the highest value of function in a variable so which command should we use

  • @ShauryaTrivedi10
    @ShauryaTrivedi10 2 роки тому +1

    It helps me a lot

  • @kychemclass5850
    @kychemclass5850 Рік тому

    Thank you for your effort.

  • @K_EN_VisheshSaini
    @K_EN_VisheshSaini 2 роки тому +1

    Is there any way to generate random numbers from scratch without using libraries in python?

  • @PawanMishra-zt3vb
    @PawanMishra-zt3vb 4 роки тому +1

    If I want to generate random real values in exponential format ,what can I do ??
    Like : - 0.000123223e-14,
    0.13343232323+02

    • @TheProgrammingPortal
      @TheProgrammingPortal  4 роки тому +1

      I guess you can use numpy library which has exponential random method functionality.

    • @PawanMishra-zt3vb
      @PawanMishra-zt3vb 4 роки тому +1

      @@TheProgrammingPortal Actually I want the random real values population at the same time I want to make sure that these population are really under Min ,max bounds

  • @marcelamaldonado9645
    @marcelamaldonado9645 Рік тому

    thank youuu!!! so helpful!!....

  • @deemanth33
    @deemanth33 2 роки тому

    Thanks a lot its really helpful

  • @kp_broz
    @kp_broz 3 роки тому +2

    Thank you❤

  • @salsailhammita886
    @salsailhammita886 3 роки тому +1

    Thank you

  • @ahmedtaman4572
    @ahmedtaman4572 3 роки тому

    How to generate a fixed float random numbers in a specific range and make sure these numbers do not change with successive runs?!

  • @CuteAnimals650
    @CuteAnimals650 2 роки тому

    This video is helpful

  • @africadigitallibrary
    @africadigitallibrary 2 роки тому

    great

  • @roshunluchman4976
    @roshunluchman4976 Рік тому

    Hi can anybody tell me how to tell python to randomly choose 6 numbers from a range of say 1 to 10 but it cannot choose a number more than once

  • @Tr_Arlen
    @Tr_Arlen 4 місяці тому

    thankss

  • @theentirestateofalaska.4983
    @theentirestateofalaska.4983 2 роки тому

    Hey man I used the uniform method but I only want it to be a number such as 42.69 instead of 4.496596222329886 so how can I do that.

    • @TheProgrammingPortal
      @TheProgrammingPortal  2 роки тому +3

      Hi,
      Once you get some values form uniform eg. 4.475276262727, use round method or use .format - %.2f .on uniform result. This will help for number of decimal or precision you want to take.
      Refer format method
      docs.python.org/3/tutorial/inputoutput.html
      Round method
      docs.python.org/3/library/functions.html#round
      Hope this helps.

  • @kofiswisconsin1552
    @kofiswisconsin1552 11 місяців тому

    👍

  • @rahulbene1754
    @rahulbene1754 2 роки тому

    👍👍👍

  • @irshadbaruah7961
    @irshadbaruah7961 2 роки тому

    How to plot this random number to visualise

  • @sokaribobaruch3103
    @sokaribobaruch3103 2 роки тому

    Thanks

  • @BHARAT_TECH23
    @BHARAT_TECH23 3 роки тому

    Tq u sir but this video is not sufficient for all concept pls make 1,2 videos more in this topic

    • @TheProgrammingPortal
      @TheProgrammingPortal  3 роки тому +1

      Thank you for the feedback. Will surely try to add few more videos in future.

  • @thezanecampbell
    @thezanecampbell 3 роки тому

    👏👍💯

  • @dhhdggvvd2978
    @dhhdggvvd2978 Рік тому

    How about Random alphabets, words...

    • @TheProgrammingPortal
      @TheProgrammingPortal  Рік тому

      Hi,
      There are a few ways you can do it with existing choices method from random modules.
      One way to have AtoZ characters with upper or lower case in variable and use that in random.choice() this is randomly choose one character from it.
      Let's say you need word of specific length, eg. Length of 10, then use for loop to generate and append in string.
      This loop can be further written using list comprehension.
      Data="avshshsbjuwhwbsjsj" # your set of characters
      Something like below.
      .join((random.choice(Data)) for x in range(10))
      Instead of using defined characters in a variable, you can explore string methods in string.ascii uppercase or lowercase.
      Refer docs.python.org/2/library/string.html
      Hope this gives enough idea to look it.