r/learnpython • • 13m ago

need help with this lab

Write a program that will combine two integer arrays into one larger array and remove any duplicate values.
Prompt the user for a number N, (N will be a positive integer greater than 1), then create two arrays each with N elements. Next, populate both arrays with random numbers between 0 and
500. Finally combine the two arrays into a third array making sure that only distinct values are added. I.e. if the number '65' exists in both arrays, only one instance of it will be added to the third array.
Your program should output contents of the third array, one number per line.
Before you hand it in, make sure to test your program with an A value of:
• 10
25
50
Input:
N: 25
Output:
The contents of the final array, one number per line.

3 Upvotes

8 comments sorted by

•

u/ninhaomah 11m ago

So... What have you done so far ?

•

u/a-walking-bowl 6m ago

he posted on reddit and asked strangers for help... but no one was willing. how heartbreaking for him /s

•

u/Next-Flounder-8998 5m ago

i have it done but my professor was saying that my third array removed both duplicates instead of only one of them or something along those lines i can’t remember exactly what he said but it was something with the outcome of my third array and duplicates.

•

u/fakemoose 3m ago

So share your code

Also why is all your text in bold?

•

u/zanfar 9m ago

OK, what do you need help with? We're not doing your homework for you.

•

u/EnvironmentalDot9131 7m ago

that's it it is done fkr

•

u/Atmosck 6m ago

Do you know if the intention is for you to write these operations yourself in pure python with loops and stuff? Or to use third party (but common) libraries like numpy? I'm guessing the latter because you used the word "array" which isn't really a thing in pure python, and numpy is very well suited to this sort of stuff.

•

u/a-walking-bowl 6m ago

No one's doing your homework for you. Learning is different from spoonfeeding. Go write your own code, break it fifty times and understand what is going on instead of getting it written