How to Think Like a Computer Scientist
Learning with Python: Interactive Edition 2.0
Welcome! Take a tour, experiment with Python, join other readers in learning how to think like a computer scientist with Python.
import turtle import random def main(): tList =  head = 0 numTurtles = 10 wn = turtle.Screen() wn.setup(500,500) for i in range(numTurtles): nt = turtle.Turtle() # Make a new turtle, initialize values nt.setheading(head) nt.pensize(2) nt.color(random.randrange(256),random.randrange(256),random.randrange(256)) nt.speed(10) wn.tracer(30,0) tList.append(nt) # Add the new turtle to the list head = head + 360/numTurtles for i in range(100): moveTurtles(tList,15,i) w = tList w.up() w.goto(0,40) w.write("How to Think Like a ",True,"center","40pt Bold") w.goto(0,-35) w.write("Computer Scientist",True,"center","40pt Bold") def moveTurtles(turtleList,dist,angle): for turtle in turtleList: # Make every turtle on the list do the same actions. turtle.forward(dist) turtle.right(angle) main()
Benefits of this Interactive Textbook¶
- You can experiment with activecode examples right in the book
- Click Show/Hide Code button
- On line 7: change
numTurtles = 10to
numTurtles = 6
- Click the Run button
- You can do your homework right in the textbook.
- You can interact with other learners to discuss homework
- Interactive questions make sure that you are on track and help you focus.
- Codelens helps you develop a mental model of how Python works.
- Audio Tours help you understand the code.
- Short videos cover difficult or important topics.
- You can highlight text, and take notes in scratch editors
About this Project¶
This interactive book is a product of the Runestone Interactive Project at Luther College, led by Brad Miller and David Ranum. There have been many contributors to the project. Our thanks especially to the following:
- This book is based on the Original work by: Jeffrey Elkner, Allen B. Downey, and Chris Meyers
- Activecode based on Skulpt
- Codelens based on Online Python Tutor
- Many contributions from the CSLearning4U research group at Georgia Tech.
- ACM-SIGCSE for the special projects grant that funded our student Isaac Dontje Lindell for the summer of 2013.
The Runestone Interactive tools are open source and we encourage you to contact us, or grab a copy from GitHub if you would like to use them to write your own resources.