Runtime error - question

Asked

Viewed 563 times

1

In this problem, you should read the code of a part 1, the number of pieces 1, the unit value of each part 1, the code of a part 2, the number of pieces 2 and the unit value of each piece 2. After, calculate and show the amount to be paid.

Entree

The input file contains two rows of data. In each row there will be 3 values, respectively two integers and a value with 2 decimal places.

Exit

The output should be a message according to the example given below, remembering to leave a space after the two points and a space after the "R$". The value should be displayed with 2 boxes after the point.

código_peça_1 = int(input())
número_peça_1 = int(input())
valor_peça_1 =  float(input())
código_peça_2 = int(input())
número_peça_2 = int(input())
valor_peça_2 =  float(input())
valor_a_pagar = ( número_peça_1 * valor_peça_1 ) + ( número_peça_2 * valor_peça_2 )
print("VALOR A PAGAR = R$ %.2f" %valor_a_pagar)

1 answer

1

The input file contains two rows of data.

Then you should do only two input readings and divide the values:

entrada = input().split()
codigo_1 = int(entrada[0])
quantidade_1 = int(entrada[1])
valor_1 = float(entrada[2])

entrada = input().split()
codigo_2 = int(entrada[0])
quantidade_2 = int(entrada[1])
valor_2 = float(entrada[2])

And thus calculate the result.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.