Level 3: Arguments - IncrediCoders/Python1 GitHub Wiki

GitHubAvatar copy

Annie Conda added this page on March 15, 2025


Here is a bonus article that will tell you more about Arguments!

In addition to this bonus article, you can find other bonus articles that teach you the topics I covered in Level 3: Lists, While Loops, and File Handling.

Learn About Arguments

An argument is the information you give to a function or method so it knows exactly what to do. It's like giving instructions with details.

If Mrs. Scratcher tells Paul Python, “Bring me a pencil,” the pencil is the argument. It tells him what to bring. Without it, he wouldn’t know what to do.

Arguments vs. Parameters

These two words are very similar, but they have different roles:

  • A parameter is the placeholder inside the function definition. It's like a blank space that’s waiting to be filled.
  • An argument is the actual value you send into the function when you use it.

Think of it like writing a birthday card:

The card has a line that says:

"Happy Birthday, [name]!" That’s the parameter (name).

When Paul Python gives the card to Grafika Turtle and fills in “Happy Birthday, Grafika Turtle,” that’s the argument.

Why Arguments Matter

Arguments help you reuse the same function or method in different ways. Instead of writing the same code over and over, you can just pass different arguments to make things happen.

Python Example

In Python, you pass arguments inside the parentheses when calling a function.

Scenario:

Paul Python writes a function to greet someone by name.

def greet(name):
    print("Hello, " + name + "!")

greet("Annie Conda")
greet("Grafika Turtle")

This will print:

Hello, Annie Conda!
Hello, Grafika Turtle!

In this example:

  • name is the argument.
  • You can reuse the same function and just give it a different name each time.

Comparing Programming Languages

All programming languages use arguments to pass information into functions or methods, though the syntax can look different.

Python

def greet(name):
    print("Hello, " + name + "!")

Java

public void greet(String name) {
    System.out.println("Hello, " + name + "!");
}

C#

public void Greet(string name) {
    Console.WriteLine("Hello, " + name + "!");
}

What’s the Difference?

  • In all three, the argument (name) is passed to the function to customize the greeting.
  • Python is the most beginner-friendly with less code.
  • Java and C# need extra keywords like public, void, and the data type (String or string), but they work the same way.

Arguments are how we give our code the right information. Just like asking a friend to bring a pencil, snack, or backpack. You need to say what you want. Arguments let you do that in code.

Learn More

TBD

Next Steps

Next, you can take on the two extra challenges and a bonus challenge to add to your Classroom Quiz program and learn more! When you're done, you can move on to Level 4, the Space Wars game!

Take the Challenges!

  1. Challenge 1: Add a score to the game, so you can try to get all the questions right. When the game ends, display the score!

  2. Challenge 2: Make the text of the answer choices turn red and green to show which one is the correct answer, as a visual feedback effect.

  3. Bonus Challenge: First, you're going to load in a new quiz with more questions! Then, you're going to add in some of your own quiz questions! Finally, you're going to make your own quiz about whatever you want!

More Level 3 Resources

In addition to this Help page and the instructions for our Level 3 challenges, we also have Online Articles, a Learning Quiz, an Unplugged Activity, and a Rewards article:

  • Level 3: Online Articles - I made you a list of different web pages I found, which will help you learn more about creating a Classroom Quiz.

  • Level 3: Learning Quiz - I wrote some questions in case you want to quiz yourself about what you learned. Or you can teach others and quiz them!

  • Level 3: Unplugged Activity - I wrote this page with more details than what you saw in the book. In this game, you'll have one person act as the developer, and one person act as the variable where the developer chooses a noun for the variable to say in the story that they tell!

  • Level 3: Rewards - If you completed the Class Introductions project that we talked about, then I set up this page to act as a reward. You can see some illustrations of me and learn more about who I am! You'll also find the Apple Award digital download, to show off your accomplishment!

Level 4

After you're completely done with Level 3 (did you do the challenges?), then it's time to move on to Level 4! While you read through Level 4 in your book, you can check out the resources from SideWinder, as she teaches you how to build the Space Wars game:

I hope you had fun learning about Classroom Quiz! This is something that is very important for all of the future levels! Enjoy!

-- Annie

⚠️ **GitHub.com Fallback** ⚠️