asked 61.8k views
2 votes
Write a program in python and PHP to compute the average of three numbers

1 Answer

3 votes

Final answer:

To compute the average of three numbers in Python and PHP, you can use simple programs that ask the user for input and calculate the average using the given inputs.

Step-by-step explanation:

To compute the average of three numbers in Python, you can write the following program:

num1 = int(input('Enter first number: '))
num2 = int(input('Enter second number: '))
num3 = int(input('Enter third number: '))
average = (num1 + num2 + num3) / 3
print('The average is:', average)

In PHP, you can use the following code:

$num1 = readline('Enter first number: ');
$num2 = readline('Enter second number: ');
$num3 = readline('Enter third number: ');
$average = ($num1 + $num2 + $num3) / 3;
echo 'The average is: ' . $average;

answered
User Jdbs
by
8.5k points