How to generate random numbers in python?



How to generate random numbers in python?..

Answer / Vishal Sharma

To generate random numbers in Python, use the built-in module 'random'. For example: n import randomn random_number = random.randint(1, 10) - Generates a random integer between 1 and 10.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Explain tkinter in python

1 Answers  


What is the difference between if and elif in python?

1 Answers  


What is lambda in Python?

1 Answers  


How do you represent binary and hexadecimal numbers?

1 Answers  


What animals sleep the least?

1 Answers  


Difference between python list comprehension vs. Map?

1 Answers  


How to reverse a string in python

1 Answers  


Name the function which helps to change the files permission

1 Answers  


What is a static method in python?

1 Answers  


How long will it take to learn python?

1 Answers  


If you installed a module with pip but it doesn’t import in your idle, what could it possibly be?

1 Answers  


How do you break in python?

1 Answers  


Categories