Python Math: Generate random float numbers in a specific numerical range
48. Random Float Generation
Write a Python program to generate random floating numbers in a specific numerical range.
Sample Solution:
Python Code:
import random
for x in range(6):
print('{:04.3f}'.format(random.uniform(x, 100)), end=' ')
Sample Output:
16.329 17.326 54.024 13.229 68.952 87.039
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to generate and print a list of 6 random floating-point numbers within a specified range using random.uniform().
- Write a Python function that generates random floats in a given range and returns them as a formatted string with 3 decimal places.
- Write a Python script to generate random floats within a user-specified range and then calculate and print their average.
- Write a Python program to create a list of random floats using random.uniform() and then sort and print the list in ascending order.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to convert a floating point number (PI) to an approximate rational value on the various denominator.
Next: Write a Python program to generate random integers in a specific numerical range.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.