Assume that ph has been assigned a float. Write an if-else-if statement
that compares ph to
7.0 and makes the following assignments (respectively) to
the variables neutral, base, and acid:
0,0,1 if ph is less than 7
0,1,0 if ph is greater than 7
1,0,0 if ph is equal to 7

Respuesta :

An if-else-if statement that compares ph to 7.0 and makes the following assignments (respectively) to the variables neutral, base, and acid:

  • 0,0,1 if ph is less than 7
  • 0,1,0 if ph is greater than 7
  • 1,0,0 if ph is equal to 7

The Program:

ph=int(input("Enter ph value: "))#input ph value

if ph < 7:#defining if block that checks ph value less than 7      

  neutral = 0#holding value in neutral variable    

  base = 0#holding value in base variable    

  acid = 1#holding value in acid variable

elif ph > 7:#defining elif block that checks ph value greater than 7    

  neutral = 0#holding value in neutral variable    

  base = 1#holding value in base variable    

  acid = 0#holding value in acid variable

else:#else block    

  neutral = 1#holding value in neutral variable    

  base = 0#holding value in base variable    

  acid = 0#holding value in acid variable

print(neutral, base , acid)#print value

The above program defines a variable "ph" that inputs an integer value and then follows up with the conditional statement that checks ph values that can be defined

Read more about if-else statements here:

https://brainly.com/question/18736215

#SPJ1

ACCESS MORE