Home

Tutoring

Subjects

Live Classes

Study Coach

Essay Review

On-Demand Courses

Colleges

Games

Opening subject page...

Loading your content

  1. My Subjects
  2. AP Computer Science Principles
  3. Flashcards

AP Computer Science Principles Flashcards: Program Function And Purpose

Study Program Function And Purpose in AP Computer Science Principles with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

← Back to flashcard decks

What this deck covers

This deck focuses on Program Function And Purpose, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

AP Computer Science Principles Flashcards: Program Function And Purpose

1

/ 30

0 reviewed

0% Complete

0 reviewing
QUESTION

What is the purpose of variable scope?

Tap or drag to reveal answer

ANSWER

To define where a variable can be accessed. Scope controls variable visibility and access.

Swipe Right = I Know It! 🎉

Swipe Left = Still Learning

All flashcards

Flashcard 1: What is the purpose of variable scope?

Answer: To define where a variable can be accessed. Scope controls variable visibility and access.

Flashcard 2: Identify the output: def f(x): return x+2; print(f(3))

Answer:

  1. Function adds 2 to input 3, returning 5.

Flashcard 3: Find the error: def increment(x): x+=1; return x; increment()

Answer: Missing argument in increment(). Function call requires one argument but none provided.

Flashcard 4: Identify the output: def f(x): return x**3; print(f(2))

Answer:

  1. Function cubes input value 2.

Flashcard 5: What is function overloading?

Answer: Defining multiple functions with the same name but different parameters. Same name functions with different parameter signatures.

Flashcard 6: What is a parameter in a function?

Answer: A variable used to pass information into a function. Parameters act as placeholders for function inputs.

Flashcard 7: Which keyword is used to define a function in Python?

Answer: def. Standard Python keyword for function declaration.

Flashcard 8: What is the purpose of the return statement in a function?

Answer: To send back a result from the function. Return transfers computed values back to caller.

Flashcard 9: Identify the error: def add(a, b): return a + b; add(1)

Answer: Missing one argument in add(1). Function requires two parameters but only receives one.

Flashcard 10: What is a function's signature?

Answer: The function's name and its parameter list. Identifies function uniquely by name and parameters.

Flashcard 11: What is the purpose of the return statement in a function?

Answer: To send back a result from the function. Return transfers computed values back to caller.

Flashcard 12: Identify the error: def add(a, b): return a + b; add(1)

Answer: Missing one argument in add(1). Function requires two parameters but only receives one.

Flashcard 13: What is the purpose of function documentation?

Answer: To describe how the function works and its parameters. Documentation explains usage, parameters, and behavior.

Flashcard 14: What is the purpose of variable scope?

Answer: To define where a variable can be accessed. Scope controls variable visibility and access.

Flashcard 15: What are side effects in a function?

Answer: Changes made by a function that affect outside state. Functions modify variables or system state externally.

Flashcard 16: What is the purpose of comments in a function?

Answer: To explain code functionality for human readers. Comments improve code readability and maintenance.

Flashcard 17: Identify the output: def f(x): return x-1; print(f(0))

Answer: -1. Function subtracts 1 from input 0.

Flashcard 18: Which keyword is used to define a function in Python?

Answer: def. Standard Python keyword for function declaration.

Flashcard 19: What is the main purpose of a function in programming?

Answer: To encapsulate reusable code logic. Functions group related code into reusable blocks.

Flashcard 20: Identify the output: f = lambda x: x + 1; print(f(5))

Answer:

  1. Lambda function adds 1 to input 5.

Flashcard 21: What is a function's signature?

Answer: The function's name and its parameter list. Identifies function uniquely by name and parameters.

Flashcard 22: What is recursion in programming?

Answer: A function calling itself to solve a problem. Self-reference enables solving complex problems iteratively.

Flashcard 23: Identify the output: def square(x): return x**2; print(square(3))

Answer:

  1. Function squares input value 3.

Flashcard 24: Identify the output: def f(x): return x+2; print(f(3))

Answer:

  1. Function adds 2 to input 3, returning 5.

Flashcard 25: Identify the output: def m(x=5): return x; print(m())

Answer:

  1. Function uses default parameter value 5.

Flashcard 26: What is a parameter in a function?

Answer: A variable used to pass information into a function. Parameters act as placeholders for function inputs.

Flashcard 27: Identify the output: def sum(a, b): return a+b; print(sum(3,4))

Answer:

  1. Function adds two arguments together.

Flashcard 28: What is a pure function?

Answer: A function with no side effects and consistent output. Pure functions have predictable, isolated behavior.

Flashcard 29: What is an anonymous function?

Answer: A function defined without a name, often using lambda. Lambda creates functions without explicit naming.

Flashcard 30: What is the output: def g(): return 10; print(g())

Answer:

  1. Function returns literal value 10.