Return to Video

FizzBuzz - Web Development

  • 0:00 - 0:04
    Okay, time for a quiz. Okay, create template that
  • 0:04 - 0:09
    when provided with the variable n prints FizzBuzz up to
  • 0:09 - 0:13
    n. Now, what is FizzBuzz? FizzBuzz is, is a
  • 0:13 - 0:16
    little programming test that's easy, it's, it's a quick way
  • 0:16 - 0:17
    to see if somebody actually knows how to program
  • 0:17 - 0:20
    simple things or not. Basically when you do FizzBuzz, I
  • 0:20 - 0:22
    want you to follow this logic. If n is
  • 0:22 - 0:26
    divisible by 3, I want you to print Fizz. If
  • 0:26 - 0:32
    n is divisible by 5, I want you to print Buzz. And if n
  • 0:32 - 0:37
    is divisible by 3 and 5, I want you to
  • 0:37 - 0:42
    report FizzBuzz. And if it's not divisible by 3 or 5, just print
  • 0:42 - 0:44
    the number. Let me show you what this will
  • 0:44 - 0:46
    look like when it's working. Okay, so here is
  • 0:46 - 0:49
    a working FizzBuzz app. I'm just going to ask you
  • 0:49 - 0:51
    to paste in the template for a FizzBuzz, but here's,
  • 0:51 - 0:52
    here's what it looks like. So if we were
  • 0:52 - 0:56
    to say FizzBuzz of n equals 100. This is
  • 0:56 - 1:00
    what it would print, one, two, three is divisible
  • 1:00 - 1:03
    by three. So it would print fizz, five is
  • 1:03 - 1:06
    divisible by five, so print buzz. Four is neither.
  • 1:06 - 1:09
    Six is three so print fizz. Come down here
  • 1:09 - 1:12
    to 15 we print FizzBuzz. So as you see
  • 1:12 - 1:16
    anything divisible three or five prints fizz or Buzz,
  • 1:16 - 1:20
    both Fizz and Buzz. And if it's neither, it just
  • 1:20 - 1:23
    prints the number. And the source that we generated looks
  • 1:23 - 1:26
    like this. It's an ordered list and then I'm just
  • 1:26 - 1:30
    printing list elements for each value as we count up
  • 1:30 - 1:34
    to n is 100. As you can see n equals
  • 1:34 - 1:37
    100 down here. The handler that I'm using looks something
  • 1:37 - 1:39
    like this. I just added this to the end of
  • 1:39 - 1:42
    the file we've been working in. I made a new url
  • 1:42 - 1:45
    called FizzBuzz which uses FizzBuzzHandler. Which is defined
  • 1:45 - 1:49
    here, which inherits from Handler. And it gets
  • 1:49 - 1:54
    n from the request defaulting to zero, converts
  • 1:54 - 1:56
    it to an integer. n and int(n) is
  • 1:56 - 1:58
    the same as basically saying if n, n
  • 1:58 - 2:03
    equals int(n). And then we're rendering fizzbuzz.html passing
  • 2:03 - 2:08
    in n equals n. What I want you to do for this quiz is generate fizzbuzz.html.
  • 2:08 - 2:10
    And once you've got that working, I'd like
  • 2:10 - 2:12
    you to paste that right here. Okay, good luck.
Cím:
FizzBuzz - Web Development
Leírás:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
CS253 - Web Development
Duration:
02:14
Udacity Robot edited Angol subtitles for 08-17 FizzBuzz
Udacity Robot edited Angol subtitles for 08-17 FizzBuzz
Cogi-Admin edited Angol subtitles for 08-17 FizzBuzz

English subtitles

Felülvizsgálatok Compare revisions