woodward.karen59
woodward.karen59 3d ago • 0 views

Procedure Call Examples in Python

Hey everyone! 👋 Struggling a bit with understanding how procedures (or functions, as we call them in Python) work when you call them? Like, what happens when you pass arguments, or when a function doesn't return anything? I'm trying to wrap my head around different ways to call them and see some good examples. Can anyone help clarify this for me? 💡
💻 Computer Science & Technology
🪄

🚀 Can't Find Your Exact Topic?

Let our AI Worksheet Generator create custom study notes, online quizzes, and printable PDFs in seconds. 100% Free!

✨ Generate Custom Content

1 Answers

✅ Best Answer
User Avatar
brittney384 Mar 18, 2026

🧠 Quick Study Guide: Python Procedure Calls

  • 🎯 Definition: In Python, procedures are typically referred to as functions. They are blocks of organized, reusable code that perform a single, related action.
  • ⚙️ Defining a Function: Use the def keyword, followed by the function name, parentheses (), and a colon :. For example, def greet(name):.
  • 📞 Calling a Function: To execute the code inside a function, you 'call' it by using its name followed by parentheses (). For example, greet("Alice").
  • 🎁 Arguments & Parameters: Parameters are variables listed inside the parentheses in the function definition. Arguments are the actual values passed to the function when it's called.
  • 🔢 Types of Arguments: Python supports positional arguments (order matters), keyword arguments (name matters), default arguments (pre-assigned values), and arbitrary arguments (*args for non-keyworded, kwargs for keyworded).
  • ↩️ Return Values: Functions can optionally return a value using the return statement. If no return statement is present, or return is used without a value, the function implicitly returns None.
  • 🚫 Procedures vs. Functions: While often used interchangeably, strictly speaking, a procedure performs an action without returning a value, whereas a function returns a value. In Python, all 'procedures' are technically functions, and they return None if no explicit return value is specified.

📝 Practice Quiz: Python Procedure Calls

  1. What is the primary keyword used to define a function in Python?

    A) function

    B) define

    C) def

    D) proc

  2. Consider the function def calculate_area(length, width): return length * width. Which of the following is a correct way to call this function using keyword arguments?

    A) calculate_area(5, 10)

    B) calculate_area(length=5, width=10)

    C) calculate_area(width=10, 5)

    D) calculate_area(5, width=10)

  3. What will be the output of the following Python code?

    def say_hello():
        print("Hello!")
    result = say_hello()
    print(result)
    

    A) Hello! followed by Hello!

    B) Hello! followed by None

    C) None followed by Hello!

    D) An error

  4. Which type of argument allows a function to accept an arbitrary number of non-keyworded arguments?

    A) Default arguments

    B) Keyword arguments

    C) *args

    D) kwargs

  5. If a Python function is defined as def power(base, exponent=2): return base ** exponent, what will power(3) return?

    A) 9

    B) 6

    C) 27

    D) An error

  6. Which of the following statements about Python functions is TRUE?

    A) All Python functions must explicitly return a value.

    B) Functions can only accept positional arguments.

    C) A function without an explicit return statement implicitly returns None.

    D) Function names must start with an uppercase letter.

  7. Given the function definition def greet(name, message="Hello"): print(f"{message}, {name}!"), which call will print "Hi, Bob!"?

    A) greet("Bob")

    B) greet(name="Bob", message="Hi")

    C) greet("Bob", "Hi")

    D) Both B and C

Click to see Answers

1. C

2. B

3. B

4. C

5. A

6. C

7. D

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀