Python NeetCode

0.0(0)
studied byStudied by 1 person
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/70

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering Python core concepts from the lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

71 Terms

1
New cards

print

Built-in Python function that outputs text to the console.

2
New cards

string

A sequence of characters defined with quotes; can use single or double quotes in Python.

3
New cards

quotes (single/double)

Strings can be defined with either single or double quotes in Python.

4
New cards

escape character

Backslash to include special characters inside strings (e.g., escaping quotes).

5
New cards

None

Python's absence-of-value marker; represented by the None keyword.

6
New cards

NoneType

The type of the None value.

7
New cards

dynamic typing

Python allows variable types to change over time.

8
New cards

static typing

Variable types are fixed; common in languages like Java and C++. Specifically contrasted with Python's dynamic typing.

9
New cards

type conversion

Changing a value from one type to another (e.g., int('10') -> 10, float(3)).

10
New cards

int()

Converts a value to an integer; truncates decimals.

11
New cards

float()

Converts a value to a floating point number.

12
New cards

bool

Boolean type; values are True or False.

13
New cards

NoneType

The type that represents the absence of a value (None).

14
New cards

type()

Built-in function that returns the data type of a value.

15
New cards

arithmetic operators

  • (add), - (subtract), * (multiply), / (divide) in Python.
16
New cards

floor division

Operator //; divides and rounds down to an integer.

17
New cards

modulus

Operator %; returns the remainder after division.

18
New cards

exponent

Operator **; raises a number to a power.

19
New cards

shorthand operators

  • =, -=, *=, /=; modify a variable in place.
20
New cards

PEMDAS

Order of operations: parentheses, exponents, multiplication/division, addition/subtraction.

21
New cards

execution order

Code runs top-to-bottom unless control structures change flow.

22
New cards

list

Mutable, ordered collection of items; denoted with [ … ].

23
New cards

tuple

Immutable, ordered collection; denoted with ( … ).

24
New cards

dictionary

Key-value mapping; denoted with { key: value }.

25
New cards

set

Unordered collection of unique elements; created with set() or braces.

26
New cards

mutable vs immutable

Mutable (lists, dicts) can change; immutable (strings, tuples) cannot.

27
New cards

slice

Subsequence extraction using start:end:step notation.

28
New cards

negative indexing

Accessing elements from the end using negative indices (e.g., -1 for last element).

29
New cards

range

Function to generate a sequence of numbers for loops; end is exclusive.

30
New cards

index

Position of an element in a sequence; zero-based indexing.

31
New cards

len()

Returns the length of a sequence (string, list, etc.).

32
New cards

string concatenation

Joining strings using the + operator.

33
New cards

substring

A portion of a string obtained via slicing.

34
New cards

first n characters

s[:n] returns the first n characters of s.

35
New cards

last n characters

s[-n:] returns the last n characters of s.

36
New cards

string immutability

Strings cannot be modified in place; operations return new strings.

37
New cards

list append

Add an element to the end of a list.

38
New cards

list pop

Remove and return the last element; can specify index to remove.

39
New cards

in operator

Membership test; x in list/dict/set checks presence.

40
New cards

dictionary keys

Unique keys in a dictionary; used to access values.

41
New cards

dictionary values

Values stored in a dictionary; accessed via dict.values().

42
New cards

dictionary items

Key-value pairs; accessed via dict.items().

43
New cards

try/except

Error handling structure to catch and handle exceptions.

44
New cards

ValueError

Error raised when an operation receives an argument of the right type but inappropriate value.

45
New cards

ZeroDivisionError

Error raised when dividing by zero.

46
New cards

split

String method to split a string into a list using a delimiter.

47
New cards

read input

input() reads a line from standard input as a string.

48
New cards

parse input

Splitting a string (e.g., by comma) to convert into data structures.

49
New cards

read integers

Read a line, split by delimiter, convert each piece to int.

50
New cards

exception handling specificity

You can have specific except blocks (e.g., ValueError) and a generic one.

51
New cards

default argument

A function parameter with a default value; optional when calling the function.

52
New cards

type hints

Optional annotations declaring expected parameter and return types.

53
New cards

NoneType in hints

When a function returns nothing, the annotated return type can be None.

54
New cards

if statement

Conditional execution block; runs when the condition is true.

55
New cards

elif

Else-if branch in Python; additional condition checks.

56
New cards

else

Fallback block executed if previous conditions were false.

57
New cards

comparison operators

Operators like ==, !=,

58
New cards

logical operators

And, or, not; combine boolean expressions.

59
New cards

truthy/falsy

Truthiness: non-false values evaluate to True; falsy values evaluate to False.

60
New cards

default value order

Non-default parameters must come before default ones in function definitions.

61
New cards

for loop

Iterates over a sequence or range; uses range() for numeric ranges.

62
New cards

while loop

Repeats while a condition is true; requires careful increment to avoid infinite loops.

63
New cards

break

Terminate the nearest enclosing loop immediately.

64
New cards

continue

Skip the rest of the current loop iteration and continue.

65
New cards

pass

No-op placeholder; allows empty blocks without errors.

66
New cards

substring slicing rules

End index is non-inclusive; s[start:end] yields characters from start up to end-1.

67
New cards

reverse with slicing

Use [::-1] to reverse a string or sequence.

68
New cards

default parameter order rule

If a parameter has a default value, all following parameters must also have defaults.

69
New cards

split vs join

Split creates a list from a string; join combines a list of strings into one string.

70
New cards

enumerating dictionaries

Using for key in dict iterates keys; dict.items() yields (key, value) pairs.

71
New cards

importance of indentation

Indentation defines code blocks in Python; incorrect indentation causes errors.