TAC 115 Midterm 2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:36 PM on 4/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

46 Terms

1
New cards
What is a string (str)?
Text inside quotes (e.g., "hello"); used to store words or characters; immutable (cannot be changed)
2
New cards
What is an int?
A whole number (e.g., 5, -3); no decimals
3
New cards
What is a float?
A number with a decimal (e.g., 3.14, -0.5)
4
New cards
What is a bool?
A data type with only two values: True or False
5
New cards
What is a list?
A collection of multiple values stored in order using brackets (e.g., [1, 2, 3]); mutable
6
New cards
What is a for loop?
A loop that repeats code a specific number of times using a sequence like range()
7
New cards
Does a for loop repeat based on a condition?
False; it repeats based on a sequence, not a condition
8
New cards
What does list.append() do?
Adds a new value to the END of a list
9
New cards
The list.append() method adds a value to the end of a list
True
10
New cards
Do function names have to start with a letter or underscore?
Yes; they cannot start with numbers
11
New cards
What does str.join() do?
Combines elements of a list into a single string using a separator
12
New cards
The str.join() method will turn a string into a list
False; it turns a list into a string
13
New cards
Lists are immutable (not changeable)
False; lists are mutable and can be changed
14
New cards
What is a boolean expression?
An expression that evaluates to either True or False (e.g., 5 > 3)
15
New cards
What is str.isalnum()?
Returns True if all characters in the string are letters or numbers (no spaces/symbols)
16
New cards
What is len()?
Returns the number of items in a list or characters in a string
17
New cards
What does show[index] do?
Accesses the value at a specific position in a string or list (index starts at 0)
18
New cards
What does random.choice() do?
Returns a random element from a list
19
New cards
How do you know the value of a variable?
Look at what is assigned using = or trace the code step-by-step
20
New cards
What does del do?
Deletes an item at a specific index in a list (e.g., del list[0])
21
New cards
What does list.pop() do?
Removes and returns an item at a specific index (default is last item)
22
New cards
What does list.remove() do?
Removes the first occurrence of a specific value from a list
23
New cards
What does list.index() do?
Returns the index (position) of a specified value
24
New cards
What does list.sort() do?
Sorts the list in place (changes original list)
25
New cards
What does sorted() do?
Returns a NEW sorted list without changing the original
26
New cards
What does range() do?
Generates a sequence of numbers used in loops (start, stop, step)
27
New cards
What does range(3) return?
0, 1, 2
28
New cards
What does range(5, 6) return?
5
29
New cards
What does range(1, 10, 2) return?
1, 3, 5, 7, 9
30
New cards
What is an infinite loop?
A loop that never ends because the condition is always True
31
New cards
What is a while condition?
The condition that controls whether the loop continues running
32
New cards
What is a while loop?
A loop that repeats as long as a condition is True
33
New cards
Difference between "and" and "or"
"and" requires BOTH conditions to be True; "or" requires at least ONE to be True
34
New cards
What does += mean?
Adds a value and assigns it back to the variable (x += 1 means x = x + 1)
35
New cards
What does a for condition do?
Controls how many times the loop runs by defining the sequence (range)
36
New cards
What does a for loop do?
Repeats a block of code for each value in a sequence
37
New cards
What does def do?
Defines (creates) a function
38
New cards
What does main() do?
A function used as the starting point of a program; calls other functions
39
New cards
What does \n do?
Creates a new line when printing text
40
New cards
What does input() return?
Always returns a string
41
New cards
How do you convert input to an integer?
Use int(input())
42
New cards
What is indexing?
Accessing elements using positions starting at 0 (first element is index 0)
43
New cards
What is slicing?
Getting a portion of a list/string using [start]; stop is NOT included
44
New cards
What happens if you go out of index range?
IndexError occurs (program crashes)
45
New cards
What does "in" do?
Checks if a value exists in a list or string (returns True/False)
46
New cards
What does not do?
Reverses a boolean value (True becomes False, False becomes True)