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

import random

random_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-hero python python3 problem-solving programming coding-challenge interview learn-python python-tutorial programming-exercises programming-challenges programming-fundamentals programming-contest python-coding-challenges python-problem-solving