random interger array question - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: random interger array question (/thread-38613.html) |
random interger array question - rpang - Nov-05-2022 I being ask to create a random integer array with the info below: ● Create two random integer array of values 0 to 14 of size ten called x and y. Concatenate x and y using the concatenate method. Assign it to Q5. my code is : np.random.seed(56) x = np.random.randint(15, size= (10)) y = np.random.randint(15, size= (10)) Q5 = np.concatenate([x,y]) print(Q5)my print: correct print is: wondering why the answer print from my code doesnt match the correct answer code. I have assign seed of 56.
RE: random interger array question - ndc85430 - Nov-05-2022 Why would you expect, when working with random numbers, to get exactly the same answer as something else? RE: random interger array question - rpang - Nov-05-2022 the answer suppose to be this : which the question is asking me to spilt the random numbers full question below: ● Create two random integer array of values 0 to 14 of size ten called x and y. Concatenate x and y using the concatenate method. Assign it to Q5. ● Use the split method on Q5 to create each of the following: Q6a: [5 3 2 5] Q6b: [ 1 5 1 11 14 10 4] Q6c: [3 9 7 6 7 7] Q6d: [14 0 4] but my code: np.random.seed(56) x = np.random.randint(15, size= (10)) y = np.random.randint(15, size= (10)) Q5 = np.concatenate([x,y]) print(Q5)my print which is wrong: generate a numbers which doesn't match the question print answer: ______________________________________________________________________________________________________________________________but if I run a code: np.random.seed(56) x = np.random.randint(15, size= (10,10)) y = np.random.randint(15, size= (10,10)) Q5 = np.concatenate([x,y]) print(Q5)with the 10,10 i can see the correct numbers are listed on line 16. wondering what is wrong with my code?thank you in advance i am quite new to python. RE: random interger array question - deanhystad - Nov-05-2022 I get your results. Are you sure about the seed value? |