8.8k views
5 votes
Write a multi-way if statement that compares the double variable pH with 7.0 and makes the following assignments to the bool variables neutral, base, and acid:

1 Answer

1 vote

Answer:

try:

pH = float(input("Enter number between 0 to 14: "))

except ValueError:

print("input must be a number")

if pH < 7:

print("pH is Acidity")

elif pH == 7:

print("pH is neutral")

else:

print("pH is Base/alkaline")(

Step-by-step explanation:

The try and except statement is used to check if the input is a number, if its not, the print statement is displayed. The nested if statement compares the pH input to know if it is an acid, base or neutral.

User Eduardo Spaki
by
4.7k points