Question

In: Computer Science

Python language: Write a function dice(n) that returns a list with the results of n dice...

Python language:

Write a function dice(n) that returns a list with the results of n dice rolls conducted with a six sided dice. Use Numpy's random number functions to do this (Hint: use randint() within numpy's random module).
i.e. dice(3) returns something like [2,3,5] to indicate the first dice obtained a 2, the second a 3 etc

Solutions

Expert Solution

Python 3

============================================================================================

import numpy as np

def dice(n):
l=np.random.randint(low=1,high=7,size=n)
return l


print(dice(3))
print(dice(7))

============================================================================================

Output


Related Solutions

Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Use Scheme Language Write a Scheme function that takes a list and returns a list identical...
Use Scheme Language Write a Scheme function that takes a list and returns a list identical to the parameter except the third element has been deleted. For example, (deleteitem '(a b c d e)) returns ‘(a b d e) ; (deleteitem '(a b (c d) e)) returns ‘(a b e).
Write a Python function that returns a list of keys in aDict with the value target....
Write a Python function that returns a list of keys in aDict with the value target. The list of keys you return should be sorted in increasing order. The keys and values in aDict are both integers. (If aDict does not contain the value target, you should return an empty list.) This function takes in a dictionary and an integer and returns a list. def keysWithValue(aDict, target): ''' aDict: a dictionary target: an integer ''' # Your code here
USING PYTHON, write a function that takes a list of integers as input and returns a...
USING PYTHON, write a function that takes a list of integers as input and returns a list with only the even numbers in descending order (Largest to smallest) Example: Input list: [1,6,3,8,2,5] List returned: [8, 6, 2]. DO NOT use any special or built in functions like append, reverse etc.
Write a Scheme function that takes a positive integer n and returns the list of all...
Write a Scheme function that takes a positive integer n and returns the list of all first n positive integers in decreasing order: (decreasing-numbers 10) (10 9 8 7 6 5 4 3 2 1) Please explain every step
PYTHON 3: Write a recursive function that takes a non-negative integer n as input and returns...
PYTHON 3: Write a recursive function that takes a non-negative integer n as input and returns the number of 1's in the binary representation of n. Use the fact that this is equal to the number of 1's in the representation of n//2 (integer division) plus 1 if n is odd. >>>numOnes(0) 0 >>>numOnes(1) 1 >>>numOnes(14) 3
Please Write-In Python Language (Topic: Word frequencies) Method/Function: List<Token> tokenize(TextFilePath) Write a method/function that reads in...
Please Write-In Python Language (Topic: Word frequencies) Method/Function: List<Token> tokenize(TextFilePath) Write a method/function that reads in a text file and returns a list of the tokens in that file. For the purposes of this project, a token is a sequence of alphanumeric characters, independent of capitalization (so Apple, apple, aPpLe are the same token). You are allowed to use regular expressions if you wish to (and you can use some regexp engine, no need to write it from scratch), but...
Using python pls!!!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a...
Using python pls!!!!! Write a recursive function gcd(m,n) that returns the greatest common divisor of a pair of numbers. The gcd of m and n is the largest number that divides both m and n. If one of the numbers is 0, then the gcd is the other number. If m is greater than or equal to n, then the gcd of m and n is the same as the gcd of n and m-n. If n is greater than...
Part A - Palindromic Bitlists Write a function palindrome binary(n) which returns a list of bitlists...
Part A - Palindromic Bitlists Write a function palindrome binary(n) which returns a list of bitlists of length n, where every bitlist is a palindrome. The returned list of bitlists must be in lexicographical order (think about the order of your options). You must use backtracking to solve this problem (i.e. do not use brute force). Part B - All Paths Write a function all paths(M, u, v) which takes as input an adjacency matrix of a graph, M, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT