English subtitles

← Days in a Month - Intro to Computer Science

Get Embed Code
6 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. For this quiz, the goal is to see that you understand lists
  2. and can define a procedure that uses them.
  3. You'll be given a variable, daysinmonth,
  4. which is initialized to a list containing 12 entries
  5. where each entry is the number of days in the corresponding month,
  6. so January has 31 days, so that's why we have 31 here.
  7. February--at least in a non-leap year--has 28 days.
  8. March has 31, and so on up to December that has 31 days.
  9. Your goal is to define a procedure called howmanydays--
  10. with underscores between the words--
  11. that takes as input a number representing a month
  12. and outputs the number of days in that month,
  13. and we should use the conventional way of numbering the months,
  14. so here's a few examples.
  15. If we call howmanydays, passing in 1,
  16. meaning the month January, the output should be 31
  17. since there are 31 days in January,
  18. and that corresponds to the entry in the zeroth position of daysinmonth.
  19. If we call howmanydays, passing in 9, that's September.
  20. We should get 30.