183k views
5 votes
Given the variables full_admission_price and discount_amount (already defined), write an expression corresponding to the price of a discount admission.

You are given two variables, both already defined, one associated with a float and named total_weight, containing the weight of a shipment, the other associated with an int and named quantity, containing the number of items in the shipment. Write an expression that calculates the weight of one item.

Write a for loop that prints all the even integers from 80 through 20 inclusive, separated by spaces.

Use Python

User Mister M
by
5.5k points

1 Answer

3 votes

Answer:

if full_admission_price = f and discount_amount = d

=> Price of a discount admission = d/f

total_weight

quantity

weight of one item = total_weight/quantity

for i in range(80, 18, -2):

print(i, end=' ')

Step-by-step explanation:

The first two questions are just mathematical to get a single quantity given some relationship. So, its basically division

For the python code, I used the python's range function which takes in three arguments. The first one is the starting value, the second one is the terminating value which is the number before the terminating value and the last one specifies the common difference popularly known as step in the language. Since the step is 2, only even numbers are printed out. In the print function, I made use of the end keyword specifying a space (' ') as the end. This ensures that the print is done in the same line with a space seperating them. Without that specification, each result will printed in a newline

User Matheus Valenza
by
4.7k points