Last Name: First: Netid:
CS 1110 Prelim 2 December 4th, 2025
This 90-minute exam has 5 questions worth a total of 100 points. Scan the whole test before starting.
Budget your time wisely. Use the back of the pages if you need more space. You may tear the pages
apart, as long as you keep everything together when you turn it in.
It is a violation of the Academic Integrity Code to look at any exam other than your
own, look at any reference material, or otherwise give or receive unauthorized help.
You will be expected to write Python code on this exam. We recommend that you draw vertical
lines to make your indentation clear, as follows:
def foo():
if something:
do something
do more things
do something last
Throughout this exam, you may use any Python feature that you have learned about in class other
than generators.
Question Points Score
1 2
2 24
3 22
4 29
5 23
Total: 100
The Important First Question:
1. [2 points] Write your last name, first name, and netid, at the top of each page.
, Last Name: First: Netid:
Reference Sheet
String Operations
Operation Description
len(s) Returns: Number of characters in s; it can be 0.
a in s Returns: True if the substring a is in s; False otherwise.
s.find(s1) Returns: Index of FIRST occurrence of s1 in s (-1 if s1 is not in s).
s.count(s1) Returns: Number of (non-overlapping) occurrences of s1 in s.
s.lower() Returns: A copy ofs with all letters converted to lower case.
s.upper() Returns: A copy ofs with all letters converted to upper case.
s.islower() Returns: True if s is has at least one letter and all letters are lower case;
it returns False otherwise (e.g. 'a123' is True but '123' is False).
s.isupper() Returns: True if s is has at least one letter and all letters are uppper
case; it returns False otherwise (e.g. 'A123' is True but '123' is False).
s.isalpha() Returns: True if s is not empty and its elements are all letters; it returns
False otherwise.
s.isdigit() Returns: True if s is not empty and its elements are all digits; it returns
False otherwise.
s.isalnum() Returns: True if s is not empty and its elements are all letters or digits;
it returns False otherwise.
s.isidentifier() Returns: True if s is a valid variable identifier (e.g. starts with a letter
or underscore, only has letters, digits and underscores).
List Operations
Operation Description
len(x) Returns: Number of elements in list x; it can be 0.
y in x Returns: True if y is in list x; False otherwise.
del x[k] Deletes the element of the list at position k.
x.index(y) Returns: Index of FIRST occurrence of y in x (error if y is not in x).
x.count(y) Returns: the number of times y appears in list x.
x.append(y) Adds y to the end of list x.
x.insert(i,y) Inserts y at position i in x. Elements after i are shifted to the right.
x.remove(y) Removes first item from the list equal to y. (error if y is not in x).
Dictionary Operations
Function
Description
or Method
len(d) Returns: number of keys in dictionary d; it can be 0.
y in d Returns: True if y is a key d; False otherwise.
d[k] = v Assigns value v to the key k in d.
del d[k] Deletes the key k (and its value) from the dictionary d.
d.clear() Removes all keys (and values) from the dictionary d.
Page 2
CS 1110 Prelim 2 December 4th, 2025
This 90-minute exam has 5 questions worth a total of 100 points. Scan the whole test before starting.
Budget your time wisely. Use the back of the pages if you need more space. You may tear the pages
apart, as long as you keep everything together when you turn it in.
It is a violation of the Academic Integrity Code to look at any exam other than your
own, look at any reference material, or otherwise give or receive unauthorized help.
You will be expected to write Python code on this exam. We recommend that you draw vertical
lines to make your indentation clear, as follows:
def foo():
if something:
do something
do more things
do something last
Throughout this exam, you may use any Python feature that you have learned about in class other
than generators.
Question Points Score
1 2
2 24
3 22
4 29
5 23
Total: 100
The Important First Question:
1. [2 points] Write your last name, first name, and netid, at the top of each page.
, Last Name: First: Netid:
Reference Sheet
String Operations
Operation Description
len(s) Returns: Number of characters in s; it can be 0.
a in s Returns: True if the substring a is in s; False otherwise.
s.find(s1) Returns: Index of FIRST occurrence of s1 in s (-1 if s1 is not in s).
s.count(s1) Returns: Number of (non-overlapping) occurrences of s1 in s.
s.lower() Returns: A copy ofs with all letters converted to lower case.
s.upper() Returns: A copy ofs with all letters converted to upper case.
s.islower() Returns: True if s is has at least one letter and all letters are lower case;
it returns False otherwise (e.g. 'a123' is True but '123' is False).
s.isupper() Returns: True if s is has at least one letter and all letters are uppper
case; it returns False otherwise (e.g. 'A123' is True but '123' is False).
s.isalpha() Returns: True if s is not empty and its elements are all letters; it returns
False otherwise.
s.isdigit() Returns: True if s is not empty and its elements are all digits; it returns
False otherwise.
s.isalnum() Returns: True if s is not empty and its elements are all letters or digits;
it returns False otherwise.
s.isidentifier() Returns: True if s is a valid variable identifier (e.g. starts with a letter
or underscore, only has letters, digits and underscores).
List Operations
Operation Description
len(x) Returns: Number of elements in list x; it can be 0.
y in x Returns: True if y is in list x; False otherwise.
del x[k] Deletes the element of the list at position k.
x.index(y) Returns: Index of FIRST occurrence of y in x (error if y is not in x).
x.count(y) Returns: the number of times y appears in list x.
x.append(y) Adds y to the end of list x.
x.insert(i,y) Inserts y at position i in x. Elements after i are shifted to the right.
x.remove(y) Removes first item from the list equal to y. (error if y is not in x).
Dictionary Operations
Function
Description
or Method
len(d) Returns: number of keys in dictionary d; it can be 0.
y in d Returns: True if y is a key d; False otherwise.
d[k] = v Assigns value v to the key k in d.
del d[k] Deletes the key k (and its value) from the dictionary d.
d.clear() Removes all keys (and values) from the dictionary d.
Page 2