Problem 134703 · easy · Phase 01 Prerequisites & Setup

Umbrella or Raincoat?

conditionals · boolean logic

A weather app gives packing advice from the chance of rain (percent) and the wind speed (km/h). Write umbrella_advice(rain_chance, wind_kmh) that returns:

  • "raincoat" if rain is at least 50% likely and the wind is at least 30 km/h (an umbrella would flip)
  • "umbrella" if rain is at least 50% likely but the wind is lighter
  • "pack umbrella" if rain is at least 20% likely but below 50%
  • "no umbrella" otherwise

Examples

Input:  rain_chance = 80, wind_kmh = 10
Output: "umbrella"

Input:  rain_chance = 80, wind_kmh = 40
Output: "raincoat"

Input:  rain_chance = 10, wind_kmh = 50
Output: "no umbrella"

Constraints

  • 0 <= rain_chance <= 100
  • 0 <= wind_kmh <= 200

Goals

  • Combine two measurements in one condition
  • Order branches so the most specific condition is tested first
Starting Python…