Use Python 3 in Jupyter
Write a function called countUnique that has one parameter which is a NumPy array. The array will be a list of integers with many repeated values. The function should count how many times each unique integer appears and return the counts. For example, if it is given the array array([3, 3, 3, 1, 1, 3, 1, 1, 3, 2]), it should return the counts [(1, 4), (2, 1), (3, 5)] since 1 appears 4 times, 2 appears once, and 3 appears 5 times.
In a separate code cell, create an create a NumPy array of 20 random integers from 1 to 20. Use your countUnique to determine how many times each number appears.
In a separate code cell, create an create a NumPy array of 10,000 random integers from 1 to 5. Use your countUnique to determine how many times each number appears.
Python 3 code
============================================================================================
import numpy as np
arr=np.random.randint(1,20,size=20)
print(arr)
unique_elements, counts_elements = np.unique(arr,
return_counts=True)
for i in range(len(counts_elements)):
print("(",unique_elements[i],",",counts_elements[i],")",end="
")
============================================================================================
Jupyter Output

for 1 to 5 10000 times

Use Python 3 in Jupyter Write a function called countUnique that has one parameter which is...
In python, Write short programs (notebook cells) showing how to create & use the following data types: Tuples Ints Floats Dictionaries Sets Numpy array The programming details are provided in a separate Jupyter notebook file
Python For this one use the random library. First, create a function called getRands that will have a parameter called ceiling. Within that function, create a loop that will loop the 10 times and in each loop, it creates a variable that is an integer between 1 and the number in the variable ceiling. Then test if that integers is less than 3. If it is, print that number. Now call getRands and pass in the argument: 10. You must...
Write a function in python, index(arr, value) to find indices of elements equal to some value in a Numpy array. The input arr is a 1-d numpy array, and input value is the value to search for. The function should return the index of the value. If the value occurs for multiple times, then all the indices should be returned as a 1-d numpy array. For example, if arr=[1 0 2 0 3 0 4 0 5 0 6 7...
(+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100) to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0 (how many) Display the number of integers < 0 (how many) Display the...
Python code define a function car that takes 'swift' as a parameter function should count how many letters in the string function should return a dictionary where key is lower case alpha caracter and value is the number of times that character appears in sentence. ex- input- that big car is so expensive output- 't':1, 'h':1, 'a':2, 'b':1, 'i':3,......
Define a function called repeat_middle which receives as parameter one string (with at least one character), and it should return a new string which will have the middle character/s in the string repeated as many times as the length of the input (original) string. Notice that if the original string has an odd number of characters there is only one middle character. If, on the other hand, if the original string has an even number of characters then there will...
For this program you create a program with multiple functions using C++ 1) You will need a function that creates an array of 100 random numbers that are generated between and including 20 and including 40. This must be a two dimensional array of 10 numbers in a row with a total of 10 rows. 2) A function that will store the array of random numbers in a data file called "rannum". 3) A function must then read the data...
please use python thanks will rate!!
x + Run C Code Validate Implement the function step_random_walk_20(x_coords, Y_coords) below, which should take two arrays of equal length containing the x-andy- coordinates for some number of particles. We'll use a very simple random walk algorithm • For each particle, choose a random angle between 0 and 2 • The particle moves by 1 unit of distance in the direction given by d.o. It is displaced by (Ax, Ay) (cos, sino). We'll do...
IN PYHTON CODE
Question #3 Produce a function prime_factors.dict that has one integer variable n that is assumed to be greater than 1. The function will return a dictionary with keys the integers from 2 to n, inclusive, and with values the set of prime factors of each key. So, the command prime_factors.dict (8) will return the dictionary 2 123,3: 3),4 2),5 (53,6 2,3),7:7),8 {2)) Note that even though the prime number 2 appears twice in the prime fac- torization...
with python
Write a function called linear_search which consumes a sorted list of integers and a number and linearly searches for the number in the list. Your function should return how many comparisons were made in order to find the element in the list. If the element is not in the list, your linear search should return -1 For example: