Python

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

1/39

flashcard set

Earn XP

Description and Tags

List

Python

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

Create [1,2,3], insert 0 at index 1, remove by value 2.

2
New cards

lst=[10,20,30]. Use slicing for last 2 elements reversed.

3
New cards

Check if "python" in lst=["java","python","go"]. Add "rust

4
New cards

lst=[1,2,3]*3. Result? Slice first 5 elements.

5
New cards

Sort [3,1,4,1,5] in-place. Reverse it.

6
New cards

lst=[[1,2],[3,4]]. Flatten to single list.

7
New cards

Find index of max value in [10,5,20,15].

8
New cards

Remove duplicates preserving order from [1,2,2,3,1].

9
New cards

lst=[1,2,3] + [4,5]. Difference from extend?

10
New cards

List comprehension: squares of even numbers in [1,2,3,4,5].

11
New cards

t=(1,2,3). Access second element. Why t[1]=4 fails?

12
New cards

Unpack (a,b,c) = (10,20,30). Swap a,b using tuple.

13
New cards

t=(1,2,3) * 2. Result? Slice elements 2-5.

14
New cards

Create single-element tuple. Common mistake?

15
New cards

points = [(1,2),(3,4)]. Extract all x-coords.

16
New cards

t=(1,[2,3]). Modify inner list. Why tuple still mutable?

17
New cards

Compare (1,2) < (1,3). Tuple comparison rules?

18
New cards

for i, (x,y) in enumerate([(1,2),(3,4)]): print(i,x+y)

19
New cards

Convert "abc" string to tuple of chars.

20
New cards

t=(1,2,3). Count occurrences of 2.

21
New cards

s={1,2,3}. Add 4, remove 2, check if 3 exists.

22
New cards

s1={1,2}, s2={2,3}. Intersection, union, difference.

23
New cards

From "hello" string, create set of unique chars.

24
New cards

s={1,2,3}. Pop random element. Clear it.

25
New cards

s1 & s2, s1 | s2, s1 - s2, s1 ^ s2. Meanings?

26
New cards

s={1,2,3}. Update with [3,4,5]. Result?

27
New cards

Check s1.issubset({1,2,3}), s1.issuperset({1}).

28
New cards

From [1,2,2,3,3], create set preserving insertion order (3.7+).

29
New cards

Frozen set from {1,2}. Why use it as dict key?

30
New cards

s.discard(5) vs s.remove(5). Difference?

31
New cards

d={'a':1}. Get 'a' value (default 0 if missing).

32
New cards

d={'x':10,'y':20}. Keys, values, items as lists.

33
New cards

Merge d1={'a':1}, d2={'b':2} using update().

34
New cards

d={'a':1,'b':2}. Pop 'a', get 'a' with default.

35
New cards

Dict comprehension: {k:k**2 for k in range(3)}.

36
New cards

Check if 'x' in d={'x':10} (key vs value).

37
New cards

fromkeys(['a','b'], 0). Result?

38
New cards

Sort dict by values: {'b':2,'a':1} → ?

39
New cards

Nested: d={'users':{'alice':25,'bob':30}}. Access bob's age.

40
New cards

d.get('x', d.setdefault('x', 0)). Purpose?