This classroom-tested, workbook-style text teaches basic programming by guiding readers to write Python programs that mimic interactive chatbots. Unlike textbooks with opaque examples explained in dry, monotonous code, Python Practice Lab engages readers immediately, with more than thirty motivating and hands-on examples. Readers learn by writing fun, working programs that gradually become more difficult as new concepts are introduced. Most exercises are open ended, promoting creativity in the process of learning. Along with coding practice, the book offers brief introductions to a range of other topics in computer science, including recommendation systems, computer vision, and big data, and relates these subjects to the programming concepts covered in the book. Python Practice Lab will be an essential resource for anyone who wants to learn to program, instructors teaching Python to beginners, and students who want to supplement their coursework by building compete and functional programs.
- Uses natural language and text strings rather than math as the main building blocks for learning about program structure
- Rewrites code comprehension exercises in equivalent code with inclusive and approachable variables rather than terse, single-letter variables
- Challenges readers to write a full program in each chapter
- Presents a selection of projects at the end of the book that integrates the concepts introduced in previous chapters
Angelica Lim is assistant professor in computing science at Simon Fraser University. An award-winning roboticist and a champion for diversity in computer science, she is the founder of Invent the Future, a summer enrichment program at SFU begun in partnership with the nonprofit AI4ALL. Victor Cheung is lecturer in computing science at Simon Fraser University. An experienced educator teaching a wide range of computer science courses from general introduction to programming to specialized human-centered computing, he is an advocate for improving user experience and user empowerment via user-centered design approaches.
- Preface
- Guiding Principles
- 1 Introduction to Computer Science
- 1.1 Welcome to CS!
- 1.1.1 Learning Outcomes
- 1.1.2 Alien Explanations
- 1.1.3 Writing and Running Your Programs
- 1.1.4 Motivational Quote Generator
- 1.1.5 Review Questions
- 1.1.6 Practice Exercises
- 1.1.7 Glossary
- 2 Chatbots
- 2.1 Chatbots with Personality
- 2.1.1 Learning Outcomes
- 2.1.2 Greetings Chatbot
- 2.1.3 How’s It Going Bot
- 2.1.4 Horoscope Bot
- 2.1.5 Review Questions
- 2.1.6 Practice Exercises
- 2.1.7 Glossary
- 2.2 Chatbots with Loops
- 2.2.1 Learning Outcomes
- 2.2.2 A Robust Bot
- 2.2.3 Food Bot
- 2.2.4 Measuring Things in Canada
- 2.2.5 Bubble Tea Menu
- 2.2.6 Mind Reader Game
- 2.2.7 Review Questions
- 2.2.8 Practice Exercises
- 2.2.9 Glossary
- 3 Recommendation Systems
- 3.1 Popularity Contest
- 3.1.1 Learning Outcomes
- 3.1.2 Popular Cafe Finder
- 3.1.3 Chip Rater
- 3.1.4 Movie Rater
- 3.1.5 Review Questions
- 3.1.6 Practice Exercises
- 3.1.7 Glossary
- 3.2 Finding Your Match
- 3.2.1 Learning Outcomes
- 3.2.2 Data Files
- 3.2.3 Favourite Pets
- 3.2.4 Similarity Score
- 3.2.5 Who Is Most Similar to You?
- 3.2.6 Review Questions
- 3.2.7 Practice Exercises
- 3.2.8 Glossary
- 4 Graphics and Computer Vision
- 4.1 Interactive Drawings
- 4.1.1 Learning Outcomes
- 4.1.2 Basic Turtle Commands
- 4.1.3 Interactive Drawing with Turtle
- 4.1.4 Cookie Drawer
- 4.1.5 Review Questions
- 4.2 Image Processing
- 4.2.1 Learning Outcomes
- 4.2.2 Green or Not?
- 4.2.3 Image Magic
- 4.2.4 Cool Colours Module
- 4.2.5 Review Questions
- 4.2.6 Practice Exercises
- 4.3 Drawing Trees
- 4.3.1 Learning Outcomes
- 4.3.2 Intro to Recursion
- 4.3.3 Recursion Revisited
- 4.3.4 Review Questions
- 4.3.5 Practice Exercises
- 5 Internet and Big Data
- 5.1 Searching
- 5.1.1 Learning Outcomes
- 5.1.2 Linear Search
- 5.1.3 Binary Search
- 5.1.4 Review Questions
- 5.1.5 Practice Exercises
- 5.2 Sorting
- 5.2.1 Learning Outcomes
- 5.2.2 Selection Sort
- 5.2.3 Merge Sort
- 5.2.4 Review Questions
- 5.2.5 Practice Exercises
- 5.3 Map, Filter, Reduce
- 5.3.1 Learning Outcomes
- 5.3.2 Review Questions
- 5.3.3 Practice Exercises
- 6 Expert Projects
- 6.1 Audio-Visual Language Learning Chatbot
- 6.2 Interactive Image Processor
“The main strength of the book is its workbook-like approach. Its example-led paradigm starts with specific examples for implementation, then introduces the topics necessary to implement those examples—an approach that fits better with how people actually program.”—David A. Joyner, author of A Teacher’s Guide to Conversational AI: Enhancing Assessment, Instruction, and Curriculum with Chatbots
“I found this book to be a highly engaging and practical resource for introducing fundamental concepts of computer science, particularly through the lens of interactive chatbots, which could instantly prove to be an attraction to learners. The book is quite hands-on and offers a problem-solving approach that heightens learner engagement”—Aakash Tyagi, Texas A&M University
“This book encourages students to get their hands dirty—to start programming and playing with code on day one. There is a nice narrative flow that introduces a task and then introduces more Python to enable students to accomplish enhancements to the initial task. The tone is welcoming and encouraging—you can feel the energy of the authors in the text.”—Anne Bracy, Cornell University