Ask Question

Create an empty list called resps. Using the list percent_rain, for each percent, if it is above 90, add the string 'Bring an umbrella.' to resps, otherwise if it is above 80, add the string 'Good for the flowers?' to resps, otherwise if it is above 50, add the string 'Watch out for clouds!' to resps, otherwise, add the string 'Nice day!' to resps. Note: if you're sure you've got the problem right but it doesn't pass, then check that you've matched up the strings exactly.

+2
Answers (1)
  1. 1 October, 12:53
    0
    resps = []

    percent_rain = [77, 45, 92, 83]

    for percent in percent_rain:

    if percent > 90:

    resps. append ("Bring an umbrella.")

    elif percent > 80:

    resps. append ("Good for the flowers?")

    elif percent > 50:

    resps. append ("Watch out for clouds!")

    else:

    resps. append ("Nice day!")

    for r in resps:

    print (r)

    Explanation:

    *The code is in Python.

    Create an empty list called resps

    Initialize a list called percent_rain with some values

    Create a for loop that iterates through the percent_rain. Check each value in the percent_rain and add the required strings to the resps using append method

    Create another for loop that iterates throgh the resps and print the values so that you can see if your program is correct or not
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Create an empty list called resps. Using the list percent_rain, for each percent, if it is above 90, add the string 'Bring an umbrella.' to ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers