We will also talk about random numbers. This means choosing a number by chance, not knowing in advance what it will be. This is how computers simulate playing cards and rolling dice. (Cards and dice are truly random, in a fair game; in a computer, since it's a program, it's pseudo-random.)
See page 10 of the handout for a random walk. See the program bug for a simple, silly example.
Working by yourself or with your partner, write a program surprise with (at least!) these three elements:
- randomly chosen regular polygon or star
- drawn in a randomly chosen location
- in a randomly chosen color
You'll need three sets of if statements to make this work. See page 10 for one set of if statements.
I usually prefer to work with a set of colors that I have chosen in advance, but you can make your colors completely random — the post below this one tells how.
Suggestion: work on the three required elements separately, then combine them. Everything you need to know is in the Logo handout! The beauty of programming is that you don't have to do it in a prescribed way; you are free to invent your own alternative way of doing things.
Submit your work by showing it to me at your desk, then copying the text of your program (with all its procedures) into an e-mail to me. If you work with another student, then make sure that both programmers send me the e-mail.
No comments:
Post a Comment