Libraries (College Board AP® Computer Science Principles): Flashcards

1/11

0Still learning

Know0

Cards in this collection (11)

  • Define library.

    A library is a collection of pre-written procedures that can be imported and used in a program.

  • Define API.

    An API (Application Programming Interface) is a set of rules and specifications that defines how procedures in a library can be used.

  • Name three things an API tells a programmer.

    An API tells the programmer what procedures are available, what parameters they accept, and what values they return.

  • Why does using a library simplify development?

    The programmer only needs to understand the API, not the internal implementation.

  • Why do programmers read API documentation?

    Programmers read API documentation to understand what a procedure does without needing to read its source code.

  • Name three sources that code used in a program can come from.

    Code can come from existing libraries, other programmers, or online sources.

  • Well-written API documentation includes ________ showing how to call each procedure correctly.

    Well-written API documentation includes examples showing how to call each procedure correctly.

  • True or False?

    RANDOM(3, 7) can return the value 7.

    True.

    RANDOM(a, b) returns an integer from a to b inclusive, so 7 is possible.

  • True or False?

    Calling RANDOM with the same arguments always produces the same result.

    False.

    Each time RANDOM is called it may produce a different result, even with the same arguments.

  • What are the possible values displayed by this code segment?

    num ← RANDOM(2, 4)
    
    DISPLAY(num * 10)

    The possible values are 20, 30, and 40, because num can be 2, 3, or 4.

  • Name two common uses of random values in programs.

    Common uses include simulating events, generating test data, and creating games.

Sign up to unlock flashcards

or