Skip to main content
EasyPalmCards

Flash card deck22 cardsBeginnerAnyone

Python basics flash cards

Twenty-two flash cards on Python fundamentals: variables, data types, lists, dictionaries, loops, functions and common errors, with short code examples.

Use this template Study now

Free to use, edit, print and study. No account needed: your set stays on this device.

The cards, front and back

  1. 1
    Front

    print()

    Back

    Displays output on the screen.

    print('Hello, world') shows Hello, world.

  2. 2
    Front

    Variable

    Back

    A name that stores a value. Python creates it when you assign to it with =.

    score = 10

  3. 3
    Front

    Basic data types

    Back
    • int: whole numbers, such as 42
    • float: decimals, such as 3.14
    • str: text in quotes, such as 'cat'
    • bool: True or False
  4. 4
    Front

    input()

    Back

    Reads a line typed by the user and always returns it as a string.

    name = input('Your name? ')

  5. 5
    Front

    Type conversion

    Back

    Change a value's type with int(), float() or str().

    age = int(input('Age? ')) turns the typed text into a whole number.

  6. 6
    Front

    Arithmetic operators

    Back
    • + add, - subtract, * multiply, / divide (gives a float)
    • // floor division (whole-number result)
    • % modulus (remainder)
    • ** power: 2 ** 3 is 8
  7. 7
    Front

    Comparison operators

    Back

    == equal, != not equal, < less than, > greater than, <= and >=. Each comparison gives True or False.

  8. 8
    Front

    if, elif, else

    Back

    Run code only when a condition is True.

    if score >= 50:

        print('Pass')

    else:

        print('Try again')

  9. 9
    Front

    Indentation

    Back

    Python uses indentation (usually four spaces) to show which lines belong to a block, such as the body of an if, loop or function. Wrong indentation causes an IndentationError.

  10. 10
    Front

    for loop

    Back

    Repeats code for each item in a sequence.

    for i in range(3):

        print(i)

    prints 0, 1 and 2.

  11. 11
    Front

    range()

    Back

    Produces a sequence of numbers. range(5) gives 0 to 4; range(2, 6) gives 2 to 5; range(0, 10, 2) gives even numbers 0 to 8.

  12. 12
    Front

    while loop

    Back

    Repeats code as long as a condition stays True. Make sure the condition eventually becomes False, or the loop never ends.

  13. 13
    Front

    List

    Back

    An ordered, changeable collection in square brackets.

    fruits = ['apple', 'pear']

    fruits.append('plum') adds an item.

  14. 14
    Front

    Indexing

    Back

    Items are numbered from 0. fruits[0] is the first item and fruits[-1] is the last.

  15. 15
    Front

    len()

    Back

    Returns the number of items in a list or characters in a string.

    len('cards') is 5.

  16. 16
    Front

    Dictionary

    Back

    Stores key and value pairs in curly braces.

    ages = {'Ana': 15, 'Ben': 16}

    ages['Ana'] gives 15.

  17. 17
    Front

    Tuple

    Back

    An ordered collection in round brackets that cannot be changed after it is created.

    point = (3, 4)

  18. 18
    Front

    Defining a function

    Back

    Use def, a name, brackets for parameters and a colon.

    def greet(name):

        return 'Hi ' + name

  19. 19
    Front

    return

    Back

    Sends a value back from a function to the code that called it. A function with no return gives None.

  20. 20
    Front

    f-string

    Back

    A string with an f before the quote that inserts values inside curly braces.

    f'You scored {score} points'

  21. 21
    Front

    try and except

    Back

    Handles errors without crashing.

    try:

        n = int(text)

    except ValueError:

        print('Not a number')

  22. 22
    Front

    Comment

    Back

    A note for humans that Python ignores. It starts with #.

    # work out the total

How to use this template

This deck covers the Python basics you need in the first weeks of a programming course: variables, data types, input and output, decisions, loops, lists, dictionaries, functions and simple error handling. It suits school computing students, university beginners and self-taught learners. Code examples are kept short so they fit on a card; indentation is shown with spaces. Use Learn mode to read each example, then type it into a Python editor and run it. Switch to Test mode and let spaced repetition keep the syntax fresh. Print double-sided for a desk reference while you code.

Tips

  • Type every example into a real Python editor. Running code teaches far more than reading it.
  • Change one thing in each example and predict the result before you run it.
  • Learn the difference between = (assign) and == (compare). Mixing them up is a classic beginner bug.
  • Remember that input() always returns a string. Convert it before doing maths.
  • When an error appears, read the last line of the message first. It names the type of error.

Make it fit

  • Add cards for modules your course uses, such as random, math or turtle.
  • Add string methods like upper(), split() and strip() for a text-processing unit.
  • For exam-board pseudocode courses, add the matching pseudocode on the back of each card.
  • Advanced learners can add list comprehensions, classes and file handling.

Updated October 28, 2026