Question

In PYTHON Write a program that # 1) Creates a list of 25 numbers that are...

In PYTHON

 Write a program that
    # 1) Creates a list of 25 numbers that are all different
    # 2) Takes a user-input number and then determines which number in the list is closest
         to the user-input number.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import numpy as np
import random
list=[]
for i in range(25):
r=random.randint(1,100)
if r not in list: list.append(r)
print(list)

myNumber = int(input("Enter Number : "))
myArray = np.array(list)

pos = (np.abs(myArray-myNumber)).argmin()
myArray[pos]
print(myArray[pos])

import numpy as np
import random
list=[]
for i in range(25):
r=random.randint(1,100)
if r not in list: list.append(r)
print(list)

myNumber = int(input("Enter Number : "))
myArray = np.array(list)

pos = (np.abs(myArray-myNumber)).argmin()
myArray[pos]
print(myArray[pos])

e in рут: [è python 3.7.0 Shell ם | lè test.py-C/Users/Administrator/Desktop/test.py (3.74) File Edit Shell Debug Options Win

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
In PYTHON Write a program that # 1) Creates a list of 25 numbers that are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT