Question 12 of 22intermediate🔧 ApplyLong Answer4 marks

Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.

Correct Answer

To calculate the number of days required for three persons A, B, and C to complete a work together, we must first accept the individual times taken by each person as input. We use the input() function to get the values for x, y, and z, and convert them to integers using `int().

The program then applies the provided formula: xyz/(xy+yz+xz)xyz / (xy + yz + xz). In Python, multiplication is performed using the *operator and division using the/operator. We calculate the numerator asx * y * zand the denominator asx * y + y * z + x * z`.

Finally, the result is stored in a variable and displayed using the print() statement.

python

Program to calculate time taken to complete work together

x = int(input("Enter days taken by A: ")) y = int(input("Enter days taken by B: ")) z = int(input("Enter days taken by C: "))

Calculate days using the formula

days_together = (x * y * z) / (x * y + y * z + x * z)

print("Work will be completed in", days_together, "days")

Exercise: EXERCISE | Q: 12 | (Page 32)
For More Understanding

Explanation

The question requires implementing a specific mathematical formula in Python. The context provides examples of arithmetic operations and variable assignments (e.g., SI calculation and average calculation). The solution follows this pattern by taking integer inputs, performing arithmetic operations using appropriate operators (* for multiplication and / for division), and printing the result.

Solution Steps

  1. Step 1: Accept the number of days taken by persons A, B, and C individually as integer inputs using int(input()).

  2. Step 2: Apply the formula xyz/(xy+yz+xz)xyz / (xy + yz + xz) using arithmetic operators to calculate the time taken if they work together.

  3. Step 3: Store the result in a variable (e.g., days_together).

  4. Step 4: Print the calculated result.