Question

In: Computer Science

Python Chemicals can be described as either acids or bases. The pH scale measures the concentration...

Python Chemicals can be described as either acids or bases. The pH scale measures the concentration of hydrogen ions in a chemical to determine just how acidic or basic it is. For this task you are going to determine whether a chemical is acidic or basic based on its pH value, and how strongly it has that property. Remember, don't call input() or print() anywhere, just use the parameters provided and return statements.

You must have at least one conditional in each function. You cannot import any module. A couple of the tasks have individual restrictions; note them, as we will remove points for any task that does not follow the requirements.

def chemical_strength(pH): Accepts one floating point parameter for the pH value, and then:

  • Determines if the pH value is valid (pH must be between 0 and 14 inclusive).

  • You’ll return the string "bad measurement" if pH value doesn't make sense.

  • Determines a description of the chemical based on its pH value.

    o A pH of less than 7 is an acidic chemical, however, we will be more specific:

  • ▪ a pH value less than or equal to 1 is a "very strong acid"
    ▪ a pH value between 1 and 4 (exclusive) is a "strong acid"
    ▪ a pH value of exactly 4 is a "plain acid"

    ▪ a pH between 4 and 6 (exclusive) is a "weak acid"

    ▪ a pH value greater than or equal to 6 is a "very weak acid"
    o A pH of more than 7 is a basic chemical, however, we will be more specific:

    ▪ a pH value less than or equal to 8 is a "very weak base"
    ▪ a pH value between 8 and 10 (exclusive) is a "weak base"
    ▪ a pH value of exactly 10 is a "plain base"
    ▪ a pH value between 10 and 13 (exclusive) is a "strong base"▪ a pH value greater than or equal to 13 is a "very strong base"

    o If the pH is exactly 7, the chemical is simply "neutral"

  • Returns the strength description as a string, e.g. "weak acid", "very strong base" etc.• Examples:

    o #pH is in between 4 and 6
    chem_strength(4.7) → 'weak acid'

    o # pH is outside of the valid pH range chem_strength(15.43) → 'bad measurement'

Solutions

Expert Solution

#source code:

def chemical_strength(pH): #here no print function is used
   if(pH>=0 and pH<=14):
       if(pH<7):
           if(pH<=1):
               return "very strong acid"
           elif(pH>1 and pH<4):
               return "strong acid"
           elif(pH==4):
               return "plain acid"
           elif(pH>4 and pH<6):
               return "weak acid"
           elif(pH>=6):
               return "very weak acid"
       elif(pH>7):
           if(pH<=8):
               return "very weak base"
           elif(pH>8 and pH<10):
               return "weak base"
           elif(pH==10):
               return "plain base"
           elif(pH>10 and pH<13):
               return "strong base"
           elif(pH>=13):
               return "very strong base"
       elif(pH==7):
           return '''"neutral","weak acid", "very strong base"'''
   else:
       return   "bad measurement"

print(chemical_strength(4.7)) #display for output
print(chemical_strength(15.43)) #display for output thats why here used print function
              
           

#source code in image format:

#output:

#if you have any doubts comment below...if you like give thumbs up....


Related Solutions

classify the following solution as acids, bases or neutral based on their pH values water soda...
classify the following solution as acids, bases or neutral based on their pH values water soda pop vomit battery acid milk hand soap coffee blood orange juice drain cleaner Part B classify each substance as strong acid, strong base, weak acid, or weak base H2SO4 HBr HI H2SO3 (CH3)2NH CH3COOH HCLO4 H3PO4 NAOH LiOH can(OH)2 KOH C6H5COOH NH3
I am going to a lab next week on Acids, Bases, PH and Buffers, but i...
I am going to a lab next week on Acids, Bases, PH and Buffers, but i need some help, especially on Buffers. Q.5 Which solution(s) showed the greatest and which solutions(s) showed little or no change change in pH? Why? regarding which ones, i do understand that i need to do the lab first. I understand bufferss resist a change in PH when a small amount of strong acid OR strong base is added to it. This means that the...
Equilibria with Weak Acids & Weak Bases - Results Exp Composition Total Vol pH 1 A...
Equilibria with Weak Acids & Weak Bases - Results Exp Composition Total Vol pH 1 A few mL of 0.10M NH3 (unchanged) n/a 11.13 2 2.5mL 0.1M NH3 & 7.5mL H2O 10 ml 10.82 3 2.5mL 0.1M NH4Cl & 7.5mL H2O 10 ml 6.01 4 2.5mL 0.1M NH3 & 2.5mL 0.1M NH4Cl & 5mL H2O 10 ml 9.26 5 Take 1mL Solution #4 and add 9mL of water 10 ml 9.26 Solution 1. Use the concentration of NH3 and the...
Many organic molecules act as acids and bases and can exist in an acid or base...
Many organic molecules act as acids and bases and can exist in an acid or base form. For each molecule, match the following acid or base with its' conjugate base or acid 1. CH3NH2 2. CH3CH2O- 3. CH3CH2N(CH3)3+ 4. CH3CH2OCH3 5. (CH3)3NH+ a.CH3NH3+ b. (CH3)2NH2+ c. CH3CH2O- d. CH3CH2OH e.(CH3)3N f. CH3CH2OOH g. none of these
A proton can accept an electron pair. This illustrates which definition of acids and bases? Amphoteric,...
A proton can accept an electron pair. This illustrates which definition of acids and bases? Amphoteric, Bronsted-Lowry, Arrhenius, or Lewis
Which of the following amino acids pairs would form the described hydrogen bond at pH 7?...
Which of the following amino acids pairs would form the described hydrogen bond at pH 7? Explain your answer? A. His Asp B. Tyr His C. Ser Arg D. Glu Thr A certain protein has a molecular weight of 250 kD. What is the approximate number of amino acids residues? A. 2 B. 750 C. 1200 D. 2300 E. 27500
what kind of concentration effects can be seen in the self assembly of amino acids?
what kind of concentration effects can be seen in the self assembly of amino acids?
How can regional concentration of firms in an industry lead to external economies of scale? Give...
How can regional concentration of firms in an industry lead to external economies of scale? Give examples of these types of industrial clusters in the United States. Are they always beneficial?
The molar concentration of HCL in a solution used to remove boiler scale from plumbing can...
The molar concentration of HCL in a solution used to remove boiler scale from plumbing can be determined by titration with a NaOH solution. 10 ml. of the HCL solution is placed in a 125 ml. beaker; 50 ml. of DI water are added along with 1 – 2 drops of phenolphthalein solution. It took 44.0 l. of 0.125M NaOH solution to reach an end point. Write the reaction for the equation, calculate the number of moles of NaOH required...
Determine the pH of an HNO2 solution of each concentration. In which cases can you not...
Determine the pH of an HNO2 solution of each concentration. In which cases can you not make the simplifying assumption that x is small? a. 0.250 M b. 0.0500 M c. 0.0250 M
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT