Question

Write a Python program that creates a set of ten elements with random numbers between 1...

Write a Python program that creates a set of ten elements with random numbers between 1 and 100, and then prints out the values in sorted order

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student,

below i have written the complete python code as per the requirement.

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

Program:

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

import random

#create an empty list

numbers = []

#loop through 10 times

for i in range(10):

    #generate a number between 1 and 100

    num = random.randint(1, 100)

    #append the number into list

    numbers.append(num)

#sort the numbers

numbers.sort()

#print the sorted numbers

print(numbers)


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

Screen shot of the code

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

Sample Output:

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

Kindly Check and Verify Thanks...!!!

Add a comment
Know the answer?
Add Answer to:
Write a Python program that creates a set of ten elements with random numbers between 1...
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