Question

Write a complete program that will generate equally likely random shoe sizes in the inclusive range...

Write a complete program that will generate equally likely random shoe sizes in the inclusive range [5, 13.5], with whole or half sizes allowed. The number of values to generate will be input by the program user. It will also count and display the total number of times small (5, 5.5, 6, 6.5) and large (12, 12.5, 13, 13.5) sizes are generated. We have provided skeleton code for you to use. You must implement the helper method as given in the starter code. Your output must also match this sample run exactly (user input indicated in bold): Enter number of shoe sizes to generate: 15 shoe sizes: 5.0 12.5 10.0 12.5 10.5 5.0 12.0 10.0 7.5 7.5 8.0 13.0 7.5 5.5 6.5 Total number of extreme sizes is: 8

Homework Answers

Answer #1

Since there is no skeleton code or the preferred language provided, below is the code for the required code in python:

import random
x=15
l=[]
for i in range(x):
  num=0.5*round(uniform(10, 27))
  l.append(num)
print(l)

small=0;large=0;
for i in l:
  if i<7:
    small+=1
  if i>11.5:
    large+=1
print('No. of small sizes: '+str(small))
print('No. of large sizes: '+str(large))
print('Total number of extreme sizes is:',str(small+large))


#OUTPUT
#[8.0, 8.5, 7.5, 13.0, 13.0, 9.0, 8.0, 13.0, 9.0, 5.0, 11.0, 13.0, 12.0, 8.0, 7.5]
#No. of small sizes: 1
#No. of large sizes: 5
#Total number of extreme sizes is: 6
Know the answer?
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
Similar Questions