Learn How to Think with Karel the Robot. About
Preface
Computer programming is fun. Telling a machine what to do, and then watching it actually do it, is amazing. Programming is all about breaking complex problems into simpler ones which are easier to solve. Interacting with the computer will teach you how to be accurate, use logic, solve problems, persevere, overcome failure, and get things done. These are tremendously important life skills which will help you succeed in anything you will do in the future.
Now, you might ask: "Why should I lose time with Karel the Robot - an educational programming language - when I can start right away learning a real programming language such as Python, C++ or Java?" The answer is that computer programming is like driving a car: One thing is to learn how to operate the vehicle - start it, shift gears, push the gas pedal and brakes, etc. But another, even more important thing is to learn the traffic rules really well: What should you do when you are coming to an intersection? Who has the right of way? What are the meanings of the traffic lights and symbols? In short - how to become a good driver. In the context of computer programming, Karel will teach you how to be such a good driver. And after that, it will be incredibly easy for you to learn how to operate various other "cars" which are other languages such as Python, Java or C++.
By the way, Karel is not a toy language at all. It can solve very hard problems including classical world-class programming challenges such as the Eight Queens puzzle which you can find on Wikipedia. Karel also can parse binary trees using recursion, implement sorting algorithms, perform statistical experiments, or read Braille text:
About Karel the Robot
The educational programming language Karel the Robot was created at the Stanford University by Dr. R.E. Pattis who also wrote the original textbook Karel the Robot: A Gentle Introduction to the Art of Programming in the 1980s. At that time, its syntax was influenced by Pascal, a major programming language of that era. We have updated the language to be compatible with Python, while preserving Dr. R.E. Pattis’ original ideas. Python is a major programming language of modern engineering and science.
About the Author
Dr. Pavel Solin is Professor of Computational Science at the University of Nevada, Reno. He has used the first 8-bit computers to draw ornaments on the screen of small black and white TV when he was 9. There were no computer monitors yet, and games were stored on audio casettes. Much changed since then but Dr. Solin’s passion for computers and programming remained the same. Today he is using the most powerful supercomputers to understand what happens inside of collapsing stars and other natural processes that cannot be observed or measured. He is fluent in several computer languages, wrote hundreds of thousands of lines of code, leads open source software projects, and enjoys learning new things every day.
Acknowledgment
We would like to thank educators and students for reporting bugs, suggesting new features, and providing valuable feedback. This is helping us to continuously improve the self-paced interactive Karel course in NCLab, as well as this textbook and the NCLab computing platform itself.
Table of Contents
- About
- 1. Introduction
- 2. Basic Commands
- 3. Counting Loop
- 4. Conditions
- 5. Conditional Loop
- 6. Custom Commands
- 7. Variables
- 8. Functions
- 9. Text Strings
- 10. Testing Your Programs
- 11. Boolean Values, Variables, Expressions, and Functions
- 12. Randomness and Probability
- 13. Lists
- 14. Recursion
- 15. Advanced Applications
- Appendix A. Karel App in NCLab
- Appendix B. Self-Paced Karel Course in NCLab