Question
please write in python
Write a program that asks for beginning and ending number. The program generates a set of 20 random numbers between the numbe
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import random;
def printLine(listOfRandom):
mylist=[];
mylist = list(dict.fromkeys(listOfRandom));
for i in mylist:
count=0;
for j in listOfRandom:
if(j==i):
count=count+1;
print(str(i)+" occurs "+str(count)+" times\n");

stringinput=input("enter starting and ending number separated by comma:");
listOfRandom=[];
begin=int(stringinput.split(",")[0]);
end=int(stringinput.split(",")[1]);
for i in range(0,20):
ranval=random.randrange(5,25);
listOfRandom.append(ranval);
listOfRandom.sort();
printLine(listOfRandom);

Expected output:

enter starting and ending number separated by comma:5,25

5 occurs 4 times

6 occurs 1 times

7 occurs 1 times

9 occurs 1 times

11 occurs 2 times

12 occurs 1 times

14 occurs 1 times

15 occurs 3 times

16 occurs 1 times

19 occurs 2 times

21 occurs 1 times

22 occurs 1 times

23 occurs 1 times

Add a comment
Know the answer?
Add Answer to:
please write in python Write a program that asks for beginning and ending number. The program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT