Hello! I am not sure how I would write in Python code that can generate random numbers without using the built-in import random function. Is this possible? So far, my code is:   import random # Define 20 random numbers between 1-100 numbers_random = [random.randint(1, 100) for _ in range(20)] # Find the lowest number of the random numbers numbers_lowest = min(numbers_random) # Find the highest number of the random numbers numbers_highest = max(numbers_random) # Define the total of all numbers numbers_total = sum(numbers_random) # Define the average of all numbers numbers_average = total / len(numbers_random) # Show all data print("Twenty random numbers:", numbers_random) print("Lowest number:", numbers_lowest) print("Highest number:", numbers_highest) print("Total of the numbers:", numbers_total) print("Average of the numbers:", numbers_average)   What I am doing with this Python code is creating 20 random numbers that are between 1-100 and showing the lowest number, highest number, the total and the averages whilst using the built-in list functions. I just want to challenge myself by not using the import random function at the top. Is there a way to do that?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello! I am not sure how I would write in Python code that can generate random numbers without using the built-in import random function. Is this possible?

So far, my code is:

 

import random

# Define 20 random numbers between 1-100

numbers_random = [random.randint(1, 100) for _ in range(20)]

# Find the lowest number of the random numbers

numbers_lowest = min(numbers_random)

# Find the highest number of the random numbers

numbers_highest = max(numbers_random)

# Define the total of all numbers

numbers_total = sum(numbers_random)

# Define the average of all numbers

numbers_average = total / len(numbers_random)

# Show all data

print("Twenty random numbers:", numbers_random)
print("Lowest number:", numbers_lowest)
print("Highest number:", numbers_highest)
print("Total of the numbers:", numbers_total)
print("Average of the numbers:", numbers_average)

 

What I am doing with this Python code is creating 20 random numbers that are between 1-100 and showing the lowest number, highest number, the total and the averages whilst using the built-in list functions. I just want to challenge myself by not using the import random function at the top. Is there a way to do that?

Expert Solution
Step 1: Introduction on the given question

In the provided scenario,The challenge is to generate random numbers in Python without using the built-in random module. Instead, we'll create a custom pseudo-random number generator to mimic the functionality of the random module. This involves designing a basic algorithm for generating random-like numbers. Keep in mind that these numbers won't be truly random, but they can simulate randomness effectively for educational purposes. The custom generator will be used to create 20 pseudo-random numbers within a specified range. The code will then calculate statistics such as the lowest number, highest number, total, and average of the generated values, much like what the random module enables. This exercise offers insight into the underlying mechanisms of random number generation and provides a valuable learning experience.

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education