Coat or t-shirt?
- O(1) · Trivial
- Free
- Python
- JavaScript
- conditionals
- strings
- comparisons
Problem
Write a function that takes the temperature outside, in degrees Celsius, and returns what to wear: "coat" below 10 degrees, "jacket" from 10 to 25, and "t-shirt" above 25.
Both edges belong to the jacket: exactly 10 and exactly 25 give you "jacket". And it can drop below zero.
Examples
3 → "coat"
18 → "jacket"
31 → "t-shirt"
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def outfit(degrees):
passJavaScript
function outfit(degrees) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.
More O(1) challenges
- Did the fever go down?lists · indexes · booleans
- Did they pass the class?booleans · conditionals
- Digits the other way rounddigits · operations
- Do the two times overlap?conditionals · booleans · comparisons
- Does it fall in range?conditionals · booleans · comparisons
- Does the photo fit the envelope?lists · conditionals · booleans