🌍 Python Programming · subject

Python Programming Python Fundamentals Syllabus

The Python Fundamentals syllabus for Python Programming in full: 5 chapters and 22 topics, every one listed below, plus 50 Python Fundamentals flashcards with answers.

5Chapters
22Topics
50Flashcards

Python Fundamentals syllabus: all 5 chapters

Expand any chapter to see its topics and sub-topics.

  1. Introduction to Python

    4 topics
    • What Python Is and Where It Is Used
    • Installing Python and Setting Up the Environment
    • Running Your First Program
    • Comments and Code Readability
  2. Variables, Data Types and Literals

    5 topics
    • Variables and Naming Rules
    • Numeric Types
    • Strings and Booleans
    • Type Conversion and Casting
    • Keywords and Reserved Words
  3. Operators and Expressions

    5 topics
    • Arithmetic Operators
    • Comparison and Logical Operators
    • Assignment and Augmented Assignment
    • Bitwise Operators
    • Operator Precedence and Associativity
  4. Input, Output and Formatting

    3 topics
    • Reading User Input with input()
    • String Formatting
    • Escape Sequences
  5. Control Flow

    5 topics
    • Conditional Statements
    • while Loops
    • for Loops and range()
    • break, continue and else Clauses
    • The match Statement

Python Programming Python Fundamentals flashcards — 50 questions with answers

  1. What is Python, and what programming paradigms does it support?

    Python is a high-level, interpreted, general-purpose programming language known for readable syntax and dynamic typing. It supports multiple paradigms: procedural, object-oriented, and functional programming.

  2. Name at least four fields or use cases where Python is commonly applied.

    Web development, data science and machine learning, automation/scripting, scientific computing, and back-end/server development. (Also game development, testing, and DevOps.)

  3. What does it mean that Python is an 'interpreted' language?

    Python code is executed line by line by an interpreter at runtime rather than being compiled to machine code ahead of time, which makes it portable and easy to test but generally slower than compiled languages.

  4. Which command-line tool is used to install third-party Python packages, and from what repository?

    The 'pip' package manager installs packages from PyPI (the Python Package Index). Example: pip install requests.

  5. How can you check the installed Python version from a terminal?

    Run python --version or python -V (on some systems python3 --version). It prints the currently active Python version, e.g., Python 3.12.0.

  6. What is a virtual environment in Python, and why is it useful?

    A virtual environment is an isolated directory containing its own Python interpreter and packages, so each project can have independent dependencies. Created with python -m venv env_name; avoids version conflicts between projects.

  7. What is the canonical first program in Python, and what function displays text?

    The classic first program prints "Hello, World!" using the built-in print() function: print("Hello, World!")

  8. How do you run a Python script named script.py from the command line?

    Type python script.py (or python3 script.py) in the terminal from the directory containing the file.

  9. What is the difference between running Python interactively (REPL) and running a script?

    The REPL (Read-Eval-Print Loop) executes statements immediately one at a time and shows results interactively; a script file runs all its code in sequence when invoked, without echoing expression results unless printed.

  10. How do you write a single-line comment in Python?

    Begin the line with the hash symbol #. Everything after # on that line is ignored by the interpreter. Example: # this is a comment

  11. Does Python have a dedicated multi-line comment syntax? How are multi-line comments typically written?

    Python has no dedicated multi-line comment syntax. Programmers either use multiple # lines, or a triple-quoted string (''' ... ''') which acts as an unassigned string literal, though technically it is a string, not a true comment.

  12. What is a docstring, and where is it placed?

    A docstring is a string literal (usually triple-quoted) placed as the first statement inside a module, function, class, or method to document it. It is accessible via the object's __doc__ attribute.

  13. Why is code readability emphasized in Python, and what document defines its style guidelines?

    Readability is core to Python's design philosophy ("readability counts"). The style guide is PEP 8, which recommends conventions like 4-space indentation, meaningful names, and line-length limits.

  14. What is a variable in Python, and how is one created?

    A variable is a named reference to a value stored in memory. It is created by assignment using =, e.g., x = 5. No explicit type declaration is needed because Python is dynamically typed.

  15. List the rules for valid Python identifier (variable) names.

    Names may contain letters, digits, and underscores; must not start with a digit; are case-sensitive; cannot be a reserved keyword; and cannot contain spaces or symbols like -, +, or @.

  16. Which of these are valid variable names: 2cool, my_var, total-price, _hidden?

    Valid: my_var and _hidden. Invalid: 2cool (starts with a digit) and total-price (contains a hyphen).

  17. What naming convention (case style) does PEP 8 recommend for variable and function names?

    snake_case: lowercase words separated by underscores, e.g., total_count. (Classes use CapWords/PascalCase; constants use UPPER_CASE.)

  18. Name the three built-in numeric types in Python and give an example of each.

    int (integers, e.g., 42), float (floating-point numbers, e.g., 3.14), and complex (complex numbers, e.g., 2 + 3j).

  19. What is the result and type of the expression $7 / 2$ in Python 3?

    The result is 3.5, and its type is float. The / operator always performs true division and returns a float in Python 3.

  20. How do you get integer (floor) division and the remainder of $17$ divided by $5$?

    Floor division uses //: $17 // 5 = 3$. The remainder uses the modulo operator %: $17 \% 5 = 2$.

Show the other 30 Python Fundamentals flashcards
  1. What are the two Boolean values in Python, and which type do they belong to?

    True and False, both of type bool. Note that bool is a subclass of int, where True equals 1 and False equals 0.

  2. How can you define a string in Python, and how do single vs. double quotes differ?

    A string is text enclosed in single quotes ('...'), double quotes ("..."), or triple quotes for multi-line. Single and double quotes are functionally identical; the choice lets you include the other quote type without escaping.

  3. Are strings mutable or immutable in Python? What does that imply?

    Strings are immutable: once created they cannot be changed in place. Operations like concatenation or replacement create new string objects rather than modifying the original.

  4. What does the built-in function int("42") do, and what happens with int("4.2")?

    int("42") converts the string to the integer 42. int("4.2") raises a ValueError, because int() cannot parse a string containing a decimal point.

  5. What is the difference between implicit and explicit type conversion (casting)?

    Implicit conversion is done automatically by Python (e.g., int + float yields float). Explicit conversion (casting) is done by the programmer using functions like int(), float(), str(), or bool().

  6. What does float(3) return, and what does str(3.14) return?

    float(3) returns 3.0 (an int cast to float). str(3.14) returns the string "3.14".

  7. Which values does bool() consider falsy in Python?

    Falsy values include: 0, 0.0, empty string "", empty collections ([], {}, (), set()), None, and False. All other values are truthy.

  8. What are keywords (reserved words) in Python, and can they be used as variable names?

    Keywords are reserved words with special meaning in the language (e.g., if, for, while, def, class, return, True, None). They cannot be used as identifiers/variable names.

  9. How can you view the full list of Python keywords programmatically?

    Import the keyword module and print keyword.kwlist, or use help("keywords") in the interpreter.

  10. List the seven arithmetic operators in Python.

    Addition +, subtraction -, multiplication *, division /, floor division //, modulo %, and exponentiation **.

  11. What does the ** operator compute, and what is the value of $2 ** 10$?

    The ** operator raises a number to a power (exponentiation). $2 ** 10 = 1024$.

  12. Name the six comparison (relational) operators in Python.

    Equal to ==, not equal to !=, greater than >, less than <, greater than or equal to >=, and less than or equal to <=.

  13. What are the three logical operators in Python and what do they do?

    and (True only if both operands are true), or (True if at least one is true), and not (inverts the Boolean value).

  14. What does 'short-circuit evaluation' mean for and / or?

    Python stops evaluating a logical expression as soon as the result is determined: for and, if the first operand is falsy it returns it immediately; for or, if the first operand is truthy it returns it immediately, skipping the second operand.

  15. What is the difference between = and == in Python?

    = is the assignment operator that binds a value to a variable. == is the comparison operator that tests whether two values are equal, returning a Boolean.

  16. What is an augmented assignment operator? Give three examples and their meaning.

    It combines an operation with assignment. x += 3 means x = x + 3; x *= 2 means x = x * 2; x //= 4 means x = x // 4. Others include -=, /=, %=, **=.

  17. What is the value of x after: x = 10; x -= 4; x **= 2?

    x starts at 10, becomes 6 after x -= 4, then becomes 36 after x **= 2 (since $6^{2} = 36$).

  18. Name the six bitwise operators in Python.

    AND &, OR |, XOR ^, NOT ~, left shift <<, and right shift >>.

  19. What does the left-shift operator do, and what is $3 << 2$?

    It shifts the bits of a number left by n positions, equivalent to multiplying by $2^{n}$. $3 << 2 = 3 \times 2^{2} = 12$.

  20. What does the bitwise AND of $5 \, \& \, 3$ evaluate to, and why?

    It equals 1. In binary $5 = 101$ and $3 = 011$; ANDing bit by bit gives $001 = 1$ (only bits set in both are kept).

  21. What is operator precedence, and where does exponentiation ** rank relative to multiplication and addition?

    Precedence determines the order operators are evaluated. Exponentiation ** has higher precedence than multiplication/division, which in turn are higher than addition/subtraction. So $2 + 3 * 4 = 14$ and $2 * 3 ** 2 = 18$.

  22. What is operator associativity, and how does the ** operator associate?

    Associativity decides grouping when operators share the same precedence. Most operators are left-associative, but ** is right-associative: $2 ** 3 ** 2 = 2 ** (3 ** 2) = 2^{9} = 512$.

  23. How do you override the default operator precedence in an expression?

    Use parentheses (). Expressions inside parentheses are always evaluated first, e.g., $(2 + 3) * 4 = 20$ instead of $2 + 3 * 4 = 14$.

  24. What does the input() function do, and what type does it always return?

    input() reads a line of text typed by the user from standard input and returns it as a string (str), even if the user types digits.

  25. How do you read an integer from the user using input()?

    Wrap input() in int(), e.g., age = int(input("Enter age: ")). The string returned by input() must be cast to int (or float) for numeric use.

  26. What is an f-string, and how is it written?

    An f-string (formatted string literal) is prefixed with f and lets you embed expressions inside curly braces {} directly in a string. Example: name = "Sam"; f"Hello, {name}!" produces "Hello, Sam!".

  27. Name three ways to format strings in Python.

    1) f-strings: f"{x}". 2) The str.format() method: "{}".format(x). 3) The older %-formatting: "%d" % x. F-strings (Python 3.6+) are the modern, preferred approach.

  28. What do the escape sequences \n and \t represent?

    \n represents a newline (moves to the next line), and \t represents a horizontal tab. Both are backslash escape sequences interpreted within strings.

  29. How do you include a literal backslash or a literal double quote inside a double-quoted string?

    Use \\ for a literal backslash and \" for a literal double quote. A raw string prefixed with r (e.g., r"C:\path") also treats backslashes literally.

  30. Write the general structure of a Python if / elif / else conditional statement.

    if condition1:\n block1\nelif condition2:\n block2\nelse:\n block3\nEach clause ends with a colon, and the associated block is indented (conventionally 4 spaces). elif and else are optional.

Python Programming Python Fundamentals FAQ

What is in the Python Programming Python Fundamentals syllabus?

Python Programming Python Fundamentals is split into 5 chapters: Introduction to Python, Variables, Data Types and Literals, Operators and Expressions, Input, Output and Formatting and Control Flow. Together they contain 22 topics.

How many chapters are in Python Programming Python Fundamentals?

5 chapters, containing 22 topics. The largest chapter is Variables, Data Types and Literals, with 5 topics.

Are there flashcards for Python Programming Python Fundamentals?

Yes — a 50-card Python Fundamentals deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.