Answer to Question #289134 in Python for ggfh

Question #289134

Write a program to generate 100 random numbers between the range 1 and 1000 and search for a number through user input.


1
Expert's answer
2022-01-20T08:27:57-0500
import random
numbers=[]
for i in range(0,100):
    numbers.append(random.randint(1,1000))


userValue =int(input("Enter the number [1-1000]: "))
index=-1
for i in range(0,100):
    if numbers[i]==userValue:
        index=i
if index!=-1:
    print("The number exists in array") 
else:
    print("The number does NOT exist in array") 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS