25.2k views
3 votes
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers.

For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 30 50 10 70 65
the output is:

20 40 0 60 55
The 5 indicates that there are five values in the list, namely 30, 50, 10, 70, and 65. 10 is the smallest value in the list, so is subtracted from each value in the list.

User Laure D
by
8.3k points

1 Answer

1 vote

Answer:

The program to this question can be defined as follows:

Program:

n = int(input("Enter the number: ")) #input value from user end

print("Entered value: ",n) #print value

lt = [] #defining an empty list

for i in range(n): # loop to input values

lt.append(int(input())) #add values in the list

minimum_value = min(lt) # finding minimum value

print("Smallest value: ",minimum_value) #print value

print("Normalising data: ") #print message

for x in lt: #defining loop normalising value

print(x-minimum_value) #print normalised values

Output:

Enter the number: 5

Entered value: 5

90

60

30

80

70

Smallest value: 30

Normalising data:

60

30

0

50

40

Step-by-step explanation:

In the given code a variable "n" is defined, that input value from the user end, in the next step, an empty list is defined, an two for loop is declared, which calculates the given value.

  • In the first for loop, the append method is used, that input values in the given list, and at the last use the min function, that prints the smallest value in the list, and stores its value in the "minimum_value".
  • In the second for loop, the "minimum_value" variable value is subtracted from the list value and print its values.
User Siddharth Agrawal
by
6.9k points