Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.05 KB

File metadata and controls

42 lines (28 loc) · 1.05 KB

Create a random number

The problem

Create a random number between 0 to 10

Hints

To create a random number, you have to import a built-in library named random. And then you can call the randint method on it

result = 4**3

Solution

importrandomrandom_num=random.randint(0,10) print(random_num)

Try it on Programming Hero

Quiz

How will you generate a random integer number?

  1. math.random
  2. random.randint
  3. random.randomint
Show Answer

The answer is : 2

Take Away

Use math.randomint to get a random integer.

  Next Page  

tags: programming-heropythonpython3problem-solvingprogrammingcoding-challengeinterviewlearn-pythonpython-tutorialprogramming-exercisesprogramming-challengesprogramming-fundamentalsprogramming-contestpython-coding-challengespython-problem-solving

close