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.
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])
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 :)
In PYTHON Write a program that # 1) Creates a list of 25 numbers that are...
Write a program that takes a list of integer numbers from a user and creates a new sorted in ascending order list. As output you need to print original list and sorted one. use list and while python
Write a Python function that creates and returns a list of prime numbers between 2 and N, inclusive, sorted in increasing order. A prime number is a number that is divisible only by 1 and itself. This function takes in an integer and returns a list of integers.
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
USE IDLE PLATFORM FOR PYTHON PLEASE Write a Python program that creates a list that contains players of your favorite teams. The program then should ask the user to enter the name of a player. If the player is in your list, display a message indicating that the player is in the team. Otherwise, the program should display a message stating that the player isn't on the team.
USING PYTHON 1. Write a small program that asks for an integer number from the user and print all the prime numbers (2,3,5,7,etc) less than the input number. 2. How long it takes for your program to print the prime numbers less than 100. (Use magic functions)
Write a Python program that creates a set of ten elements with random numbers between 1 and 100, and then prints out the values in sorted order
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
PYTHON 1- Write a program that creates a dictionary of the English words for all single digit numbers as follows: 1: 'one', 2: 'two', 3: 'three', etc. 2- Write a function called numConvert that receives the above dictionary and an integer number as parameters, and prints the English words for all the number's digits. For example, if the function receives 2311, it will print: two three one one 3- Test your program by adding a main function, which calls numConvert....
use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...
write easiest program to under stand:- a) Python program that takes three coefficients (a, b, and c) of a Quadratic equation (ax2+bx+c=0) as input and compute all possible roots b).User defined function isprime(num) that accepts an integer argument and returns 1 if the argument is prime, a 0 otherwise. Write a Python program that invokes this function to generate prime numbers between the given ranges