Exam prep · Free college course

Introduction to Computer Science: 1,117 Free Flashcards

A complete first computer science course taught in Python, built from the 14 chapters of OpenStax Introduction to Python Programming plus a searching, sorting and Big-O unit and a testing and debugging unit. It runs from statements, expressions and types through decisions, loops, functions and scope, modules, strings, lists, and dictionaries, sets and tuples, then classes, recursion, inheritance, files and exceptions. Each chapter starts with a short notes card and then mixes recall, multiple choice, cloze, typed answers, true or false, and a few sequence cards. Many cards show a short snippet and ask what it prints or which exception it raises, and the classic beginner traps are seeded throughout: integer versus float division, aliasing, the mutable default argument, scope shadowing, off-by-one errors, and == versus is. Every snippet was run in real Python 3 before it went into a card. One honest limit: cards cannot run code. This course is the concept half of CS1, terminology, tracing and prediction, so use it alongside an editor or IDE, not instead of one. It does not ask you to write programs.

1,117cards
16units
80chapters
25sources cited

Try 15 real cards, no account needed

Copied straight from the course. Pick an answer to see if you were right, and why.

  1. Card 1 of 15Which list can binary search be used on correctly?

    1. A list already sorted in ascending order
    2. Any list with fewer than 100 items
    3. A list that will be sorted after the search finishes
    4. A list in random order
    Show answer

    A list already sorted in ascending order. Binary search relies on order to decide which half can be thrown away, so its input must already be sorted.

  2. Card 2 of 15Which lists the logical operators from highest precedence to lowest?

    1. not, or, and
    2. not, and, or
    3. or, and, not
    4. and, not, or
    Show answer

    not, and, or. not binds tightest, then and, then or, all looser than the comparison operators.

  3. Card 3 of 15On [2, 5, 8, 12, 16, 23, 38, 56, 72, 91], searching for 2 (the first item), which search makes fewer comparisons?

    1. Binary search, with 1 comparison against 3 for linear
    2. Both make exactly 3 comparisons
    3. Linear search, with 1 comparison against 3 for binary
    4. Binary search, because it is always faster
    Show answer

    Linear search, with 1 comparison against 3 for binary. Best case for linear search is the first item (1 comparison). Binary search still has to narrow down to it (3 comparisons on this list).

  4. Card 4 of 15In the statement x = 5, which part is an expression?

    1. The whole line, because every statement is an expression
    2. The literal 5
    3. Nothing, because a statement never contains an expression
    4. The = sign on its own
    Show answer

    The literal 5. An expression represents a single value to be computed. In x = 5 the literal 5 is the expression, and the whole line is the statement that stores it.

  5. Card 5 of 15What does this program print? ```python print((1 + 3) ** 2 / 4) ```

    1. 1.0
    2. 16.0
    3. 4
    4. 4.0
    Show answer

    4.0. The parentheses give 4, then 4 ** 2 is 16, then 16 / 4 is 4.0; the / operator always gives a float.

  6. Card 6 of 15What is the output of this program? ```python a = [1, 2] b = a.copy() b.append(3) print(a, b) ```

    1. [1, 2, 3] [1, 2]
    2. [1, 2] [1, 2]
    3. [1, 2] [1, 2, 3]
    4. [1, 2, 3] [1, 2, 3]
    Show answer

    [1, 2] [1, 2, 3]. copy() builds a new list, so appending to b leaves a untouched.

  7. Card 7 of 15What does this program print? ```python print(bool("0"), bool(""), bool(-1)) ```

    1. False False True
    2. False True True
    3. True False True
    4. True True False
    Show answer

    True False True. "0" is a non-empty string so True, "" is empty so False, and -1 is a non-zero number so True.

  8. Card 8 of 15The body of a while loop always runs at least once. ```python while 3 < 2: print("never") print("done") ```

    1. True
    2. False
    Show answer

    False. The condition is tested first; if it is false at the start, the body never runs.

  9. Card 9 of 15Which line is a valid function header?

    1. def calc_tax(rate)
    2. def calc tax(rate):
    3. function calc_tax(rate):
    4. def calc_tax(rate):
    Show answer

    def calc_tax(rate):. A header needs def, a name without spaces, parentheses for the parameters, and a colon.

  10. Card 10 of 15After "import math", which expression correctly calls the square-root function?

    1. math.sqrt(25)
    2. sqrt(25)
    3. math(sqrt(25))
    4. sqrt.math(25)
    Show answer

    math.sqrt(25). import math binds the single name math, so its contents are reached with the dot: math.sqrt(25).

  11. Card 11 of 15What is the result of this code? ```python s = "Cloud" print(s[5]) ```

    1. IndexError
    2. d
    3. An empty string
    4. C
    Show answer

    IndexError. The string has indexes 0 to 4, so s[5] is out of range. Indexing raises IndexError, unlike slicing.

  12. Card 12 of 15What does this print? ```python nums = [10, 20, 30, 40, 50] print(nums[1:3], nums[-2:]) ```

    1. [20, 30] [50]
    2. [10, 20] [30, 40]
    3. [20, 30] [40, 50]
    4. [20, 30, 40] [40, 50]
    Show answer

    [20, 30] [40, 50]. A slice runs from the start index up to but not including the stop index, and -2 starts at the second-from-last element, giving [20, 30] and [40, 50].

  13. Card 13 of 15True or false: d.get("k") raises KeyError when the key "k" is not in d.

    1. True
    2. False
    Show answer

    False. get returns None (or the default you pass) for a missing key. Only the square-bracket form d["k"] raises KeyError.

  14. Card 14 of 15Which description matches abstraction in OOP?

    1. Copying one object so two names refer to the copy
    2. Creating many separate objects from a single class
    3. Hiding inner workings so users see only what they need
    4. Bundling data and methods into one unit with restricted access
    Show answer

    Hiding inner workings so users see only what they need. Abstraction shows only the necessary information, like a dashboard gauge that reports "in range" instead of the exact engine number.

  15. Card 15 of 15What does this program print? ```python def f(n, d=1): if n == 0: print("deepest frame:", d) return f(n - 1, d + 1) f(3) ```

    1. deepest frame: 1
    2. deepest frame: 4
    3. deepest frame: 0
    4. deepest frame: 3
    Show answer

    deepest frame: 4. f(3), f(2), f(1) and f(0) are four nested calls, so the deepest one has d = 4.

That was 15 of 1,117 cards

The rest are free too. Encodr schedules every review for you with spaced repetition, so you only see a card again when it is time.

Keep going free →

What's inside

Unit 1 Statements and the Python Environment

5 chapters · 53 cards

Unit 2 Expressions and Operators

5 chapters · 68 cards

Unit 3 Objects, Variables and Types

5 chapters · 83 cards

Unit 4 Decisions

5 chapters · 70 cards

Unit 5 Loops

5 chapters · 82 cards

Unit 6 Functions and Scope

6 chapters · 99 cards

Unit 7 Modules and Packages

3 chapters · 34 cards

Unit 8 Strings

5 chapters · 66 cards

Unit 9 Lists

6 chapters · 84 cards

Unit 10 Dictionaries, Sets and Tuples

5 chapters · 67 cards

Unit 11 Classes and Objects

6 chapters · 99 cards

Unit 12 Recursion

5 chapters · 66 cards

Unit 13 Inheritance

4 chapters · 49 cards

Unit 14 Files and Exceptions

6 chapters · 66 cards

Unit 15 Searching, Sorting and Big-O

5 chapters · 82 cards

Unit 16 Testing and Debugging

4 chapters · 49 cards

Studying it feels like a game, not a grind

Encodr is a friendly, game-like flashcard app. Spaced repetition schedules every review for you, and the rest keeps you coming back.

Daily streaks

Study a little each day to build a streak. A streak freeze forgives a missed day.

Daily quests

Small goals each day, like finishing a set, with a little celebration when you clear one.

Short study sets

Sessions come in bite-size sets of 15 to 25 answers, so there is always a natural place to stop.

Friends

Earn XP and level up, then see friends on a daily leaderboard and send them a nudge.

Questions

Is the Introduction to Computer Science course really free?

Yes. Create a free Encodr account and all 16 units and 1,117 cards are yours to study, with spaced repetition scheduling your reviews.

Can I learn to code from flashcards alone?

No, and the course does not pretend to. Cards cannot run code, so it covers the concept half of CS1: vocabulary, tracing and predicting output, scope and mutability rules, naming the exception a snippet raises, and classifying Big-O. Use it next to an editor or IDE where you write and debug real programs.

Which textbook is it based on?

OpenStax Introduction to Python Programming (chapters 1 to 14, CC BY-NC-SA 4.0), plus the Python documentation and ACM computing curricula for the searching, sorting, Big-O and testing units. The cards are rewritten, not copied.

Which Python version do the cards use?

Python 3. Every snippet was run in Python 3 before it became a card, and cards that depend on error message wording say so or ask only for the exception type.

Does it include images or diagrams?

No. Cards are text only, so call stacks and sort passes are described step by step in words.

Keep going