Question: main body for your program in this project. You should only implement these functions, it is the tester that will be calling and testing each

 main body for your program in this project. You should onlyimplement these functions, it is the tester that will be calling and

main body for your program in this project. You should only implement these functions, it is the tester that will be calling and testing each one of them. Last, be reminded that the generic structure of a function is the following: def function_name (argi, arg2, etc.) # this line is the signature # commands go here # more commands # result = return result # this line returns the result of your computations Tasks Task 1: PH Scale 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. 0 . . 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. 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: # pH is in between 4 and 6 chem_strength(4.7) 'weak acid outside of the valid pH range chem_strength(15.43) bad measurement Note: If your code always returns a single value (such as "strong acid"), you won't get credit for passing any test cases. No hard coding! Task 2: Light Switches . pH is You have the ability to adjust two switches to control the overhead lighting in your apartment. Each is on a dial than can set to switch to some integer value between 1 and 100 (inclusive). These are very precise switches, such that the light only comes if at least one of the following three circumstances are found: 1. Both switches are set to above 50 2. The sum of the switch settings is equal to the maximum value of one switch 3. The difference in the switch is equal to half the maximum value of one switch . O def light_status (si, s2): Accepts two integer parameters for the switch values, and then: Determines if the state of each switch both valid o if either switch is not valid then function should return the string 'invalid switch' Determines if the light is "on" or "off" based on the above criteria the switches must be valid for the light to be on or off! Returns the light's status ["on", "off","invalid switch") as a string Examples: O # switch 1 is invalid light status (102, 5) 'invalid switch' # light is on by criteria 2 light_status (50,50) # switches are valid, but no criteria met light_status (34,23) 'off' O 'on' Note: If your code always returns a single value (such as "on"), you won't get credit for passing any test cases. No hard coding

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!