CPSC120B
Fundamentals of Computer Science I
Day 7 Notes
Range
Cool Computer Science Thing of the Day
Reading Questions
Quiz
Emacs Tip of the Day
Range
- We’ve already seen range with single input
- If we want different values for i, can write expressions to compute them
- For example if want to start at 1, add 1 to i
- There is an easier way, range has optional arguments
- If there are two arguments they are start and stop
- If there are three arguments they are start, stop, and step
Range Peculiarities
- What happens if you use a floating point number?
- What happens if you use a floating point number that represents an integer?
- What happens if you flip the start and stop values?
- What happens if you start and stop at the same value?
- What happens if you change the loop varible, inside of the loop?
More Turtle
goto
tell the turtle to go to an x, y coordinate
- Where is the orgin?
- How big is the coordinate plane?
setheading
tell the turtle to turn to an orientation
- useful when turtle code is mixing forward and goto commands
Lab