How can I have a program that will ask a minimum and maximum number from a user?, Generate a list of 5 random numbers between the minimum and maximum numbers given, and Display another list where the values are square of the generated 5 numbers?
This is my code. I just want it to display each number with its corresponding squared number.
from numpy import random
import numpy as np
#ask minimun and maximum numbers
a=int(input("Minimum Number: "))
b=int(input("Maximum Number: "))
#random elements and elements size
x=random.randint(a,b , size=(5))
#list of 5 random elements
print("Generated Numbers:", x)
#squared of the 5 random elements
print ("Squared Numbers:", np.square(x))
Try this:
import random
value1 = int(input("Enter minimum value: "))
value2 = int(input("Enter maximum value: "))
randomValues = []
for i in range(5):
randomvalue = random.randint(value1,value2)
randomValues.append(randomvalue)
print("Got Random Values")
print(randomValues)
for value in randomValues:
squareValue = value*value
print("Sqare of value: "+str(value)+" is: "+str(squareValue))
Bro/Sis I typed this answer a bit fastly, If u got any syntax error or something else try resolve it
EDIT: *you can skip converting it to int, I thought it is in float type