PYTHON Question 3: Rain or Shine Part 1: Alfonso will only wear a jacket outside if it is below 60 degrees or it is raining. Write a function that takes in the current temperature and a boolean value telling if it is raining and it should return True if Alfonso will wear a jacket and False otherwise. Try solving this problem with a single line of code. def wears_jacket(temp, raining): """ >>> wears_jacket(90, False) False >>> wears_jacket(40, False) True >>> wears_jacket(100, True) True """ *** YOUR CODE HERE *** Note that it should either return True or False based on a single condition, whose truthiness value will also be either True or False. Part 2: Rewrite the above function with a lambda expression.
PYTHON
Question 3: Rain or Shine
Part 1: Alfonso will only wear a jacket outside if it is below 60 degrees or it is raining.
Write a function that takes in the current temperature and a boolean value telling
if it is raining and it should return True if Alfonso will wear a jacket and False otherwise.
Try solving this problem with a single line of code.
def wears_jacket(temp, raining): """ >>> wears_jacket(90, False) False >>> wears_jacket(40, False) True >>> wears_jacket(100, True) True """ *** YOUR CODE HERE *** |
Note that it should either return True or False based on a single condition, whose truthiness value will also be either True or False.
Part 2: Rewrite the above function with a lambda expression.

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









