Question: Write a python code to generate following output: a ) GENERATE 5 0 0 0 RANDOM AND UNIQUE NUMBERS AND SORT THEM b ) ASK
Write a python code to generate following output:
a GENERATE RANDOM AND UNIQUE NUMBERS AND SORT THEM
b ASK USER FOR RANDOM NUMBERS BETWEEN THOSE RANDOM NUMBERS AND FIND OUT WHERE DOES THE RANDOM MUMBER LIES BETWEEN
sUPPOSE RANDOM NUMBER IT SHOULD SHOW IT LIES BETWEEN AND
this is my code:
import random
# Generate unique numbers
uniquenumbers set
while lenuniquenumbers:
uniquenumbers.addrandomrandint
# Convert set to list
a listuniquenumbers
# Selection sort
for i in rangelena:
for j in rangei lena:
if ai aj:
ai aj aj ai
printAfter sorting:", a
n intinputEnter a random number:
start
end lena
found
while startend:
mid startend
if amidn:
found mid
break
if amidn:
end mid
else:
start mid
printFound at found
I am unsure about the second part. Can you please check my code and modify the code and show me that the code is working on python IDE. DONT JUST WRITE THE CODE.THANKS
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
