Talking to the Computer
Phase II begins! Put down the turtle and pick up words. Make the computer print messages, ask you questions, and remember your answers.
Phase II begins! Put down the turtle and pick up words. Make the computer print messages, ask you questions, and remember your answers.
Strings are the computer's words. Glue them together, measure them, make them LOUD or quiet, and repeat them — the start of real text programs.
Make the computer your calculator: add, multiply, divide, and find remainders. Plus the big gotcha — turning the text from input() into a real number.
Before a computer can make decisions, it has to answer yes/no questions. Meet True and False, the comparison signs, and the words and, or, and not.
Now your program can choose. Use if, elif, and else to do different things depending on the answer to a yes/no question.
Put input, if, and a score together to build a real quiz game that asks questions, checks answers, keeps score, and tells the player how they did.
A while loop repeats as long as something stays true. Build a countdown and a real number-guessing game that keeps asking until the player gets it right.
One variable can hold a whole collection. Meet the list — store many values, grab them by position, add new ones — the start of working with real data.
March a loop through a whole list — print every item, add them all up, count the ones you care about, find the biggest. This is what data analysis is made of.
Lists keep data in order; dictionaries label it. Store 'Ada → 90', look things up by name, and loop through labeled data — a key skill for real datasets.
In Phase I your functions drew shapes. Now they compute and hand back an answer with return — so you can use the result, combine it, and build real tools.
Build a chatbot that reads what you type and replies. Combine a while loop, keyword checks, and friendly responses into a program that holds a conversation.
The big finish for Phase II — build a branching choose-your-own-adventure game with choices, an inventory, and multiple endings. Then get ready to build games in Phase III.