Exercise 1: Number of Days in a Month
Write code to calculate the number of days in a month.
We'll cover the following
Problem statement
Given a month
containing a number from one to 12 and a leap_year
variable set to true
or false
, return the number of days in that month.
Examples
Input:
month = 3
leap_year = true
Output:
result = 31
Input:
month = 2
leap_year = true
Output:
result = 29
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy