Python 3 — Fundamentals

Preview40 cardsTechnology

Term

Python

Click card to reveal

1 / 6
👋 Tap = flip

All Terms (40)

Python

A high-level, interpreted programming language known for its readability and simplicity.

Preview

PEP 8

Python Enhancement Proposal that provides guidelines and best practices on how to write Python code.

Preview

What is a Python list?

An ordered, mutable collection of items that can be of mixed data types, defined using square brackets: `[1, 'a', True]`.

Preview

Tuple

An immutable ordered collection of items, defined using parentheses: `(1, 'a', True)`.

Preview

Dictionary

An unordered collection of key-value pairs, defined using curly braces: `{'key': 'value'}`.

Preview
Sign up to unlock

Function

A block of reusable code that performs a specific task, defined using `def` keyword.

Sign up to unlock

What is a Python module?

A file containing Python definitions and statements, intended to be imported and used in other Python programs.

Sign up to unlock

Import statement

Used to include the functionality of a module into a Python program, using the `import` keyword.

Sign up to unlock

What does `len()` do in Python?

Returns the number of items in an object like a list, tuple, or string.

Sign up to unlock

Slice

A way to retrieve a portion of a sequence by specifying a start and end index: `sequence[start:end]`.

Sign up to unlock

How does `if __name__ == '__main__':` work?

Determines if the Python file is being run as the main program. If true, it runs the code block under it.

Sign up to unlock

Lambda function

An anonymous, inline function defined with the `lambda` keyword, consisting of a single expression.

Sign up to unlock

What is list comprehension?

A concise way to create lists using a single line of code with a `for` loop inside brackets: `[x for x in range(5)]`.

Sign up to unlock

Exception

An error that occurs during the execution of a program, disrupting normal flow.

Sign up to unlock

Try-Except block

Used to handle exceptions in Python, allowing the program to continue execution.

Sign up to unlock

What is a class in Python?

A blueprint for creating objects, encapsulating data and behavior.

Sign up to unlock

Instance

An individual object created from a class.

Sign up to unlock

Inheritance

A mechanism to create a new class using the properties and methods of an existing class.

Sign up to unlock

What is a Python decorator?

A function that modifies the behavior of another function or method, often denoted with `@decorator_name`.

Sign up to unlock

Global variable

A variable defined outside of a function, accessible throughout the program.

Sign up to unlock

Local variable

A variable defined within a function, accessible only within that function.

Sign up to unlock

What does `return` do in a function?

Sends a function's result back to the caller and exits the function.

Sign up to unlock

Docstring

A string literal used to document a specific segment of code, written as the first statement in a function, module, or class.

Sign up to unlock

What is `self` in a class method?

A reference to the current instance of the class, used to access instance variables and methods.

Sign up to unlock

How do you comment a line in Python?

By using the `#` symbol at the beginning of the line.

Sign up to unlock

Boolean

A data type that can be either `True` or `False`.

Sign up to unlock

What is the `__init__` method?

A special method in Python classes used to initialize new instances, akin to a constructor.

Sign up to unlock

For loop

A control flow statement used to iterate over a sequence, like a list or string.

Sign up to unlock

While loop

A control flow statement that repeats a block of code as long as a condition is true.

Sign up to unlock

Break statement

Terminates the nearest enclosing loop, allowing the program to proceed with the next statement outside the loop.

Sign up to unlock

Continue statement

Skips the remaining code inside a loop for the current iteration and moves to the next iteration.

Sign up to unlock

What is a set in Python?

An unordered collection of unique items, defined using curly braces: `{1, 2, 3}`.

Sign up to unlock

What is Python's `range()` function?

Generates a sequence of numbers, often used in `for` loops.

Sign up to unlock

File I/O

The process of reading from and writing to files using functions like `open()`, `read()`, and `write()`.

Sign up to unlock

How does string formatting work with `f-strings`?

A way to embed expressions inside string literals, using `{}` brackets and prefixing the string with `f`.

Sign up to unlock

What is a generator?

A function that returns an iterator and is defined using `yield` instead of `return`.

Sign up to unlock

Mutable vs Immutable

Mutable objects can be changed after creation (e.g., lists), while immutable objects cannot (e.g., tuples).

Sign up to unlock

What is the GIL in Python?

Global Interpreter Lock, a mutex that protects access to Python objects, preventing multiple native threads from executing Python bytecodes at once.

Sign up to unlock

What is `pip`?

A package manager for Python that allows you to install and manage additional libraries and dependencies.

Sign up to unlock

What is the difference between `==` and `is`?

`==` checks for value equality, while `is` checks for reference (identity) equality.

Sign up free to unlock all 35 cards

Free forever. No credit card needed.

Ready to study Python 3 — Fundamentals?

Free forever. No credit card needed.