Lesson 3.3 Learning Algorithms in Coding with AI Tools like ChatGPT
Lesson 3.3 Learning Algorithms in Coding with AI Tools like ChatGPT
Writing and Converting Pseudocode
Objective: Students create pseudocode for a simple problem and convert it into Python code with ChatGPT's assistance.
1. Activity: Writing Pseudocode (20 minutes):
- Students individually write pseudocode for the AnimalSound problem:
- Example:
STARTINPUT animalIF animal == "cat" THEN OUTPUT "Meow! Meow! Meow!"ELSE IF animal == "dog" THEN OUTPUT "Bark! Bark! Bark!"ELSE OUTPUT "Unknown animal"END IFEND2. Introduction to Computational Notebooks (10 minutes):
- Teacher introduces Google Colab and Jupyter Notebook as tools for interactive coding.
- Demonstrates how to create and run cells in these environments.
3. Activity: Translating Pseudocode to Python (20 minutes):
- Students use ChatGPT to translate their pseudocode into Python code.
- Example Python Code:
python
animal =input("Enter an animal (cat or dog): ")
ifanimal.lower() =="cat":
("Meow! Meow! Meow!")
elifanimal.lower() =="dog":
("Bark! Bark! Bark!")
else:("Unknown animal.")
Students test their code in Google Colab or Jupyter Notebook.