๐What Are Comments?
Comments are notes in your code that Python ignores when running the program. They're just for humans to read! In Python, any line starting with # is a comment.
๐คKarel's Code Without Comments:
def main():
move()
jump_hurdle()
move()
jump_hurdle()
move()
โ Can you tell what this code is trying to do? It's hard to know!
โจExample With Good Comments:
def main():
move()
jump_hurdle()
move()
jump_hurdle()
move()
โ
Now it's much easier to understand what Karel is doing!
๐ฑReal-World Connection:
Think about a recipe! When you bake cookies, the recipe doesn't just say "Add ingredients." It explains each step: "Mix butter and sugar until fluffy" or "Bake for 12 minutes." Comments work the same way in codeโthey explain each step clearly!