subject

This is a warm-up prompt lab, was shown code by the teacher, I plug it in and the output is correct but the computer system won't grade it because it's getting an "EOF when reading a line" error code, any suggestions? (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts)
Ex:
Enter weight 1:
236.0
Enter weight 2:
89.5
Enter weight 3:
176.0
Enter weight 4:
166.3
Weights: [236.0, 89.5, 176.0, 166.3]
(2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (1 pt)
(3) Output the max list element with two digits after the decimal point. (1 pt)
Ex:
Enter weight 1:
236.0
Enter weight 2:
89.5
Enter weight 3:
176.0
Enter weight 4:
166.3
Weights: [236.0, 89.5, 176.0, 166.3]
Average weight: 166.95
Max weight: 236.00
(4) Prompt the user for a number between 1 and 4. Output the weight at the user specified location and the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts)
Ex:
Enter a list index location (0 - 3):
3
Weight in pounds: 176.00
Weight in kilograms: 80.00
(5) Sort the list's elements from least heavy to heaviest weight. (2 pts)
Ex:
Sorted list: [89.5, 166.3, 176.0, 236.0]

here is my code:

peopleWeights = []
num_weights = 4

for i in range(num_weights):
singleWeight = float(input('Enter weight %d:\n' % (i+1)))
peopleWeights. append(singleWeight)

print('Weights:', peopleWeights)

avgWeight = sum(peopleWeights)/len(peopleWeight s)
print('\nAverage weight: %.2f' % avgWeight)

print('Max weight: %.2f'% max(peopleWeights))

index = int(input('\nEnter a list index (1 - 4):\n'))
chosenWeight = peopleWeights[index-1]
print('Weight in pounds: %.2f' % chosenWeight)
print('Weight in kilograms: %.2f' % (chosenWeight/2.2))

peopleWeights. sort()
print('\nSorted list:', peopleWeights)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e.g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
question
Computers and Technology, 22.06.2019 12:00
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 23.06.2019 21:40
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
You know the right answer?
This is a warm-up prompt lab, was shown code by the teacher, I plug it in and the output is correct...
Questions
question
Mathematics, 19.11.2019 02:31
question
Mathematics, 19.11.2019 02:31
question
History, 19.11.2019 02:31
Questions on the website: 13722361