Midterm 2 CS122

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

1/15

encourage image

There are no tags or description

Looks like no tags are added yet.

16 Terms

1
New cards

What is recursion in programming?

A function that calls itself.

2
New cards

What is a base case in recursion?

Conditions that stop the recursion.

3
New cards

What is the purpose of the call stack?

To manage function calls in a Last-In, First-Out (LIFO) manner.

4
New cards

What happens when a function finishes executing?

Its stack frame is popped off the call stack, returning control to the calling function.

5
New cards

What is mutability?

The ability of an object to be changed after it is created.

6
New cards

Give an example of a mutable data type in Python.

Lists.

7
New cards

What is the definition of refactoring code?

Restructuring code to improve its readability, maintainability, and/or efficiency without changing its external behavior.

8
New cards

What are docstrings used for?

To document modules, classes, functions, and methods.

9
New cards

What are comments in code?

Lines of code that are not executed, used to explain logic or provide context.

10
New cards

List a common string method in Python.

isupper() or isdigit() or find() or capitalize().

11
New cards

How can you check if a substring is present in a string?

By using the 'in' operator.

12
New cards

What technique can be used to simplify complex conditional statements?

Extracting common code into functions.

13
New cards

What tools can help understand code execution and debug in Python?

Online Python tutor or visualizer tools.

14
New cards

What is the importance of understanding call stacks?

It's crucial for debugging and understanding program flow.

15
New cards

How do you iterate through individual characters in a string?

Using loops, such as a for loop.

16
New cards

What is base conversion in programming?

Converting numbers between different bases, like binary, decimal, and hexadecimal.