Placeholder Image

字幕列表 影片播放

  • One thing that computers are really good at is repeating commands.

  • As a person, you'd get really bored if you had to do the same thing lots of times in a row.

  • But a computer can do the same thing millions or even billions of times,

  • and not get bored and be able to carry that out really well.

  • So for example if I wanted to wish

  • everyone on Facebook a happy birthday by sending them an email,

  • it might take me more than a century to actually write out all of those emails to everyone.

  • But with just a few lines of code, I can have a system

  • send an email to everyone on Facebook wishing them a happy birthday.

  • So that's what loops are, and why they're valuable,

  • and something that computers can do very well.

  • In this example your goal is going to be to move the bird

  • to get the pig. Now we're gonna be able to use the "repeat" block

  • in order to be able to do this very easily. You can either do this by

  • giving the computer a "move forward" command

  • five times in order to advance the bird one step each time to the pig.

  • Or you can just tell the computer to "move forward" once,

  • and then tell it to "repeat" that 5 times, and it will do the same thing.

  • So in order to do this you drag your "move forward" command,

  • and then you put it inside the "repeat" block.

  • And you can click on it and tell it how many times you want to repeat the block

  • to tell it how many steps you want it to take forward. Now one more thing is

  • you can put as many commands as you want inside the "repeat" block.

  • So in this example you're telling it to move forward and turn left,

  • which it will do five times. Alright good job and have fun :-)

One thing that computers are really good at is repeating commands.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級 美國腔

代碼小時--馬克-扎克伯格教授重複循環。 (Hour of Code - Mark Zuckerburg teaches Repeat Loops)

  • 408 29
    赫蔡 發佈於 2021 年 01 月 14 日
影片單字