CSCI Midterm

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

1/53

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:15 PM on 12/9/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

54 Terms

1
New cards

How do you assign a value to a variable in Python?

Use variable_name = value.

2
New cards

Difference between int, float, and str?

int = whole numbers, float = decimals, str = text.

3
New cards

How do you concatenate two strings?

"hello" + "world".

4
New cards

What does input() do?

Reads user input and returns it as a string.

5
New cards

What does type() do?

Shows the data type of a value or variable.

6
New cards

Convert "25" to an integer.

int("25").

7
New cards

How do you write a comment in Python?

Use #.

8
New cards

Convert a string to lowercase.

s.lower().

9
New cards

How do you find the length of a string or list?

len().

10
New cards

What does len() return?

Number of items/characters.

11
New cards

What’s the purpose of an if-else statement?

To run different code depending on a condition.

12
New cards

What is elif used for?

Multiple conditions when if isn’t true.

13
New cards

Difference between and and or?

and: both conditions must be true; or: at least one must be true.

14
New cards

What does not do?

Reverses a Boolean value.

15
New cards

Structure of a while loop?

while condition: code.

16
New cards

How does a for loop work?

Iterates over items in a sequence (list, string, range).

17
New cards

Purpose of break?

Stops a loop immediately.

18
New cards

Purpose of continue?

Skips to the next loop iteration.

19
New cards

Print numbers 1–10 using a loop.

for i in range(1, 11): print(i).

20
New cards

Difference between list and dictionary?

List uses indexes; dictionary uses key-value pairs.

21
New cards

Create an empty list.

[] or list().

22
New cards

Append to a list.

lst.append(item).

23
New cards

Remove last item in a list.

lst.pop().

24
New cards

Access first list element.

lst[0].

25
New cards

Access last list element.

lst[-1].

26
New cards

Reverse a list using slicing.

lst[::-1].

27
New cards

Add an item to a dictionary.

d[key] = value.

28
New cards

Check if value exists in list.

value in lst.

29
New cards

Combine lists.

list1 + list2.

30
New cards

Check if string contains substring.

"cat" in s.

31
New cards

Count vowels in a string (core idea).

Loop through characters and count "aeiou".

32
New cards

Split string into words.

s.split().

33
New cards

Remove whitespace on ends.

s.strip().

34
New cards

Reverse a string.

s[::-1].

35
New cards

What does find() do?

Returns index of substring or -1 if not found.

36
New cards

Replace substring.

s.replace("old", "new").

37
New cards

Convert to uppercase.

s.upper().

38
New cards

Check if string is numeric.

s.isdigit().

39
New cards

Format a string.

f"Hello {name}".

40
New cards

Purpose of return?

Sends a value back from a function.

41
New cards

How to define a function?

def function_name(params): code.

42
New cards

Function that returns sum of two numbers.

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

43
New cards

Function that takes list and returns average.

sum / length.

44
New cards

What is an algorithm?

Step-by-step process to solve a problem.

45
New cards

Find minimum in a list?

Loop through, track smallest so far.

46
New cards

Sum elements in a list?

Use sum(lst) or loop and add.

47
New cards

Convert Celsius → Fahrenheit.

F = C * 9/5 + 32.

48
New cards

What is a local variable?

A variable created inside a function.

49
New cards

Number of parameters in def t(a,b,c,d)?

4.

50
New cards

How does binary search work?

Repeatedly splits sorted list in half to find a target.

51
New cards

What happens if list is not sorted?

Binary search fails / returns incorrect results.

52
New cards

How does insertion sort work?

Builds sorted list one element at a time by inserting into correct position.

53
New cards

Why sort a list?

Makes searching faster, organizes data.

54
New cards

Alternatives to insertion sort?

Bubble sort, Selection sort, Merge sort, Quick sort.