Return to Video

Days in a Month - Intro to Computer Science

  • 0:00 - 0:03
    For this quiz, the goal is to see that you understand lists
  • 0:03 - 0:05
    and can define a procedure that uses them.
  • 0:05 - 0:08
    You'll be given a variable, daysinmonth,
  • 0:08 - 0:11
    which is initialized to a list containing 12 entries
  • 0:11 - 0:14
    where each entry is the number of days in the corresponding month,
  • 0:14 - 0:17
    so January has 31 days, so that's why we have 31 here.
  • 0:17 - 0:20
    February--at least in a non-leap year--has 28 days.
  • 0:20 - 0:26
    March has 31, and so on up to December that has 31 days.
  • 0:26 - 0:29
    Your goal is to define a procedure called howmanydays--
  • 0:29 - 0:31
    with underscores between the words--
  • 0:31 - 0:34
    that takes as input a number representing a month
  • 0:34 - 0:36
    and outputs the number of days in that month,
  • 0:36 - 0:40
    and we should use the conventional way of numbering the months,
  • 0:40 - 0:42
    so here's a few examples.
  • 0:42 - 0:44
    If we call howmanydays, passing in 1,
  • 0:44 - 0:47
    meaning the month January, the output should be 31
  • 0:47 - 0:49
    since there are 31 days in January,
  • 0:49 - 0:54
    and that corresponds to the entry in the zeroth position of daysinmonth.
  • 0:54 - 0:57
    If we call howmanydays, passing in 9, that's September.
  • 0:57 - 1:00
    We should get 30.
Title:
Days in a Month - Intro to Computer Science
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
CS101 - Intro to Computer Science
Duration:
01:00
Udacity Robot edited English subtitles for 11-04 Days In A Month
Udacity Robot edited English subtitles for 11-04 Days In A Month
Fran Ontanaya edited English subtitles for 11-04 Days In A Month
Udacity Robot edited English subtitles for 11-04 Days In A Month
Udacity Robot edited English subtitles for 11-04 Days In A Month
Amara Bot added a translation

English subtitles

Revisions Compare revisions