So I've been really struggling with learning python. It's been killing me. It's been about 2 months now. I have 2 questions. 1. What is a simpler way to solve this problem that doesn't take 45 minutes? And 2 - how long did you have to practice Python before you became competent?
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers.
For this program, read in a list of floats and adjust their values by dividing all values by the largest value. Output each value with two digits after the decimal point. Follow each number output by a space.
Ex: If the input is:
30.0 50.0 10.0 100.0 65.0
the output is:
0.30 0.50 0.10 1.00 0.65
''' Type your code here. '''
num = input()
makeList = num.split()
biggest = float(makeList[0])
for index, value in enumerate(makeList):
if float(value) > float(biggest):
biggest = value
lastString = ""
for i in makeList:
answer = ("{:.2f}".format(float(i)/float(biggest)))
lastString += answer + " "
print(lastString)
1: Compare output 3 / 3
Input
30.0 50.0 10.0 100.0 65.0
Your output
2: Compare output 4 / 4
Input
5.0 10.0 15.0 20.0 25.0 30.0 35.0
Your output
0.14 0.29 0.43 0.57 0.71 0.86 1.00
3: Compare output 3 / 3
Input
99.9 52.5 12.6 200.0
Your output
0.50 0.26 0.06 1.00
0.30 0.50 0.10 1.00 0.65