Loops
Errors
Regular Expressions
Arrays
Recursion and Searching
100

This keyword allows you to exit a loop before the condition becomes false.

What is break?

100

This type of error occurs when you violate Python’s grammar rules, such as missing a colon.

What is a syntax error?

100

This module in Python is used for working with regular expressions.

what is re?

100

This data structure is a fixed-length, mutable collection of elements, not native to Python.

What is an array?

100

This is the part of a recursive function that stops the function from making further recursive calls.

What is the base case?

200

In Python, this keyword skips the current iteration of the loop and proceeds to the next iteration.

What is continue?

200

An error caused by incorrect logic or a mistake in the design of your program, resulting in an unexpected outcome, is called this.

What is a semantic error?

200

This regular expression function returns all occurrences of a pattern in a string.

What is re.findall()?

200

This function returns the length of an array.

What is len()?

200

This term refers to the memory structure where function calls are placed during recursion.

What is the call stack?

300

Write a while loop that prints numbers from 1 to 5.

i = 1 

while i <= 5:

    print(i)   

     i += 1

300

This block of code handles exceptions that may be raised during execution.

What is try/except?

300

Write a regular expression pattern to match any string containing digits.

pattern = r'\d+'

300

In an array, this index is used to access the last element.

len(array) - 1

300

This is the time complexity of binary search.

What is O(log n)?

400

This function can be used to generate a sequence of numbers within a for loop.

What is range()?

400

Unit test have these three steps.

What is setup, invoke & analyze?

400

This character is used in a regular expression to indicate "zero or more" occurrences of the preceding element.

What is asterisk * ?

400

Write a Python statement to access the third element in an array, and set it equal to the value 7

array[2] = 7

400

Write Python code for a linear search that returns the index of a target value in a list lst, or None if not found.

def linear_search(lst, target):

     for i in range(len(lst)):        

          if lst[i] == target:            

              return i    

     return None

500

Write a for loop that iterates over a string and prints each character. It stops if it prints a 'p'

word = "example" 

for char in word:

    print(char)

    if char == 'p':

         break

500

Write code that raises a TypeError if the variable x is not an integer.

x = "hello"

if not type(x) is int:
    raise TypeError("Only integers are allowed")

500

Write a regular expression pattern to match any lowercase letter, followed by any uppercase letter in a string.

pattern = r"[a-z][A-Z]"  

500

Write Python code to initialize an array of 5 integers, with each value equal to it's index + 10.

import array 

arr = arrays.Array(5)

for i in range(5):

     arr[i] = i + 10

500

Write Python code for a binary search that returns the index of a target value in a sorted list lst, or None if not found.

def binary_search(lst, target):    

    low = 0

    high = len(lst) - 1    

    while low <= high:        

        mid = (low + high) // 2        

        if lst[mid] == target:            

            return mid        

        elif lst[mid] < target:            

            low = mid + 1        

        else:            

            high = mid - 1    

    return None

M
e
n
u