Created
August 2, 2020 02:33
-
-
Save cybnz/7611f89254f91caddcfb493d67566fe4 to your computer and use it in GitHub Desktop.
Finds sf and checks if number and more than 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions go here | |
def num_check(question): | |
error = "Please enter a number that is more than zero" | |
valid = False | |
while not valid: | |
try: | |
response = float(input(question)) | |
if response <= 0: | |
print(error) | |
else: | |
return response | |
except ValueError: | |
print(error) | |
# Main Routine goes here | |
serving_size = num_check("What is the recipe serving size? ") | |
desired_size = num_check("How many servings are needed? ") | |
scale_factor = desired_size / serving_size | |
print("Scale factor: {}".format(scale_factor)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment