75 Python Flashcards That Built My Basics — Beginner-Friendly Notes

OsruOsru
7 min read

Table of contents

Why I Made These Notes

Hi, I’m Osru — a CSE student who didn’t find passion in tech… until I started learning Python.
After leaving a draining internship with no growth or pay, I made the bold choice to quit and invest in one skill: Python.

Within a few weeks, I’ve built small projects, solved problems on HackerRank, and consistently studied daily. To help myself (and now others), I created this set of 75 Python flashcards — covering all core basics, with definitions and examples.

These notes are:

  • Beginner-friendly ✅

  • Interview-ready 📋

  • Personal and practical 💡

Let’s dive into the flashcards! 👇

🔹 Part 1: Python Flashcards (Q1–25)

🧩 *Covers variables, strings, conditions, loops, lists, and tuples.*Python Flashcards – Part 1 (Basics & Syntax)

1. What is Python?

Python is a high-level, interpreted, general-purpose programming language known for its readability.

2. How to write a comment in Python?

Use # for single-line and triple quotes ''' ''' or `` for multi-line.

3. What is an Escape Sequence?

Used to insert special characters.

Example: \\n (new line), \\t (tab), \\\\ (backslash)

4. What is a Variable?

A variable stores data. Example: x = 10

5. How to check the type of a variable?

Use type() function: type(5) returns <class 'int'>

6. What is Type Casting?

Converting one data type to another.

Example: int("5"), float(3), str(8.1)

7. What is input() used for?

Takes user input as a string.

8. How to convert user input to number?

Use int(input()) or float(input())

9. What is String Concatenation?

Joining strings using +

Example: "Hello " + "Osru""Hello Osru"

10. What is String Slicing?

Extracting part of a string: text[0:4]

11. String Methods Example

  • upper(), lower(), strip(), replace(), split()

12. What is a List?

Ordered, mutable collection. Example: [1, 2, 3]

13. List Methods

  • append(), extend(), insert(), pop(), remove(), sort()

14. What is a Tuple?

Ordered, immutable collection. Example: (1, 2, 3)

15. How is Tuple different from List?

Tuple is immutable. List is mutable.

16. What is a Set?

Unordered collection with no duplicates. Example: {1, 2, 3}

17. Set Methods

  • add(), remove(), union(), intersection(), clear()

18. What is a Dictionary?

Key-value pairs. Example: {"name": "Osru", "age": 21}

19. Dictionary Methods

  • get(), keys(), values(), items(), update(), pop()

20. What is if-else?

Conditional control flow.

if x > 0: print("Positive")
else: print("Negative")

21. What is match-case? (Python 3.10+)

Pattern matching similar to switch-case.

22. What is a Loop?

Repeats a block of code.

23. for Loop Example

for i in range(5):
    print(i)

24. while Loop Example

i = 0
while i < 5:
    print(i)
    i += 1

25. break vs continue

  • break → exits loop

  • continue → skips to next iteration

Part 2: Python Flashcards (Q26–50)

🧩 Covers functions, docstrings, exception handling, sets, and dictionaries.

Python Flashcards – Part 2 (Functions, Errors, File I/O, Basics)

26. What is a Function?

A reusable block of code to perform a specific task.

Example:

def greet():
    print("Hello")

27. What is a Function Argument?

Values passed to a function during the call.

Example: def add(a, b): return a + b

28. What is the return statement?

It exits a function and optionally passes back a value.

29. What is Recursion?

A function calling itself to solve a smaller instance of the same problem.

30. What is a Docstring?

A string that describes what a function/class/module does.

Defined using triple quotes ``.

31. What is an f-string?

A way to format strings using variables.

Example: f"Hello {name}"

32. What is Shorthand if-else?

A one-line version of if-else.

print("Yes") if a > b else print("No")

33. What is the enumerate() function?

Returns index and item when looping through an iterable.

for i, val in enumerate(['a', 'b']):
    print(i, val)

34. What is the purpose of __name__ == "__main__"?

Used to run code only if the file is executed directly, not when imported.

35. What are Global and Local Variables?

  • Global: defined outside functions and accessible anywhere.

  • Local: defined inside a function and accessible only there.

36. What is a Virtual Environment?

An isolated environment to manage project-specific dependencies.

37. What does the import statement do?

It brings in external modules or packages to use in your script.

38. What is the os module?

Provides functions to interact with the operating system. Example: os.getcwd(), os.listdir()

39. What is Exception Handling?

Mechanism to gracefully handle runtime errors using try, except, finally.

40. What is the purpose of try and except?

To catch and handle errors to prevent crashes.

41. What is finally used for?

Runs no matter what—used for cleanup like closing files.

42. How to raise a custom error?

Use raise keyword.

raise ValueError("Invalid input")

43. What is File I/O?

Reading from and writing to files using built-in functions.

44. How to open a file in Python?

f = open("file.txt", "r")

45. What does readline() do?

Reads one line at a time from a file.

46. What does writelines() do?

Writes a list of strings to a file.

47. What is seek() in file handling?

Moves the cursor to a specific position in a file.

48. What does tell() return?

Gives the current cursor position in a file.

49. What does truncate() do?

Cuts off the file at the specified size.

50. Difference between is and ==?

  • is checks identity (same memory).

  • == checks value equality

Part 3: Python Flashcards (Q51–75)

🧩 Covers lambda functions, map/filter/reduce, comprehensions, slicing, and more.

Python_Flashcards_Part3

📘 Python Flashcards – Part 3 (Intermediate Concepts)

51. What is a Lambda Function?

A small anonymous function written using the lambda keyword.

Example: lambda x: x + 1

52. What is map() used for?

Applies a function to all items in an iterable.

list(map(lambda x: x**2, [1, 2, 3]))

53. What is filter() used for?

Filters elements based on a condition.

list(filter(lambda x: x % 2 == 0, [1, 2, 3, 4]))

54. What is reduce() used for?

Performs a rolling computation to reduce a list to a single value.

Used by importing from functools.

55. Difference between map() and filter()?

  • map() transforms all elements.

  • filter() selects specific elements based on a condition.

56. What are Built-in Functions?

Functions already available in Python like len(), max(), min(), sum().

57. What is a Module in Python?

A Python file that contains functions, classes, or variables you can import.

58. What is a Package?

A directory containing multiple modules and an __init__.py file.

59. How to install external packages?

Using pip install packagename in the terminal.

60. What is PEP8?

Python Enhancement Proposal – Style guide for writing clean Python code.

61. What is List Comprehension?

A concise way to create lists.

squares = [x**2 for x in range(5)]

62. Can we use conditionals in List Comprehension?

Yes.

Example: [x for x in range(10) if x % 2 == 0]

63. What is zip() function?

Combines two or more iterables into tuples.

zip([1, 2], ['a', 'b']) → [(1, 'a'), (2, 'b')]

64. What is the use of any() and all()?

  • any() returns True if any item is True

  • all() returns True only if all items are True

65. What is Slicing in Python?

Accessing a portion of a list or string.

a[1:4] → from index 1 to 3

66. How to reverse a list using slicing?

a[::-1]

67. How to check memory address of a variable?

Using id():

id(x)

68. Difference between is and == (again)?

  • is: identity (same memory)

  • ==: equality (same value)

69. What is the difference between input() and raw_input()?

In Python 3, only input() exists and it returns string.

70. How to convert a string to a list of characters?

list("hello") → ['h', 'e', 'l', 'l', 'o']

71. What is the difference between append() and extend()?

  • append() adds a single element.

  • extend() adds elements from another iterable.

72. Can a dictionary key be a list?

No, keys must be immutable types like strings, numbers, or tuples.

73. How to check if a key exists in a dictionary?

Use in:

if "name" in my_dict:

74. What is the use of pass?

A placeholder statement — does nothing but avoids errors.

75. What is the None keyword?

Represents the absence of a value or a null value.

🚀 Final Thoughts

These notes are part of my daily learning log. I believe sharing helps solidify knowledge — and maybe even inspire someone else starting their Python journey.

If you’re a beginner like me, save this post and review it regularly.


🧠 “Learning is not attained by chance, it must be sought for with ardor and attended to with diligence.” – Abigail Adams

0
Subscribe to my newsletter

Read articles from Osru directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Osru
Osru

👩‍💻 CSE Undergrad | Python & Data Analytics Enthusiast | Currently on a Semester Exchange at Universiti Sains Malaysia 🇲🇾 🧠 Learning Python • SQL • Power BI • Excel 🚀 Documenting my journey.