Question: We're checking for days and weather conditions. In this program, we're using nested conditionals. This is not efficient and we want to use the
We're checking for days and weather conditions. In this program, we're using nested conditionals. This is not efficient and we want to use the and logical operator instead. Re-write this nested conditional statement into a single conditional (if-elif-else) statement using the and operator. Click Run to check your code. Click Submit to submit your code to your instructor. Run 1 # Set variables 2 day="Friday" 3 weather "cloudy" 4 Redo 8 9- 5 # Write your if-else statement below 6 if day="Friday": 7- if(weather ="sunny"): 10 11 else: 12 - 13 14- 15 Save else: print("It is Friday and sunny!"). print("It is Friday and not sunny!") Submit if(weather =="sunny"): else: print("It is not Friday and sunny!") print("It is not Friday and not sunny!") Hint Your Output: Desired Output: It is Friday and not sunny!
Step by Step Solution
3.47 Rating (160 Votes )
There are 3 Steps involved in it
Python program that uses ifelifelse with and operator to disp... View full answer
Get step-by-step solutions from verified subject matter experts
