Last Name: First: Netid:
CS 1110 Prelim 1 October 16th, 2025
This 90-minute exam has 6 questions worth a total of 100 points. Read over 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; just make sure your name is on every page.
It is a violation of the Academic Integrity Code to look at any exam other than your
own, to look at any other reference material, or to otherwise give or receive unautho-
rized 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
You should not use loops or recursion on this exam. Beyond that, you may use any Python feature
that you have learned in class (if-statements, try-except, lists), unless directed otherwise.
Question Points Score
1 2
2 14
3 20
4 25
5 19
6 20
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
Throughout this exam you will be asked questions about strings and lists. You are expected to
understand how slicing works. In addition, the following functions and methods may be useful.
String Functions and Methods
Expression
Description
or Method
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.count(s1) Returns: the number of times s1 occurs in s
s.find(s1) Returns: index of the first character of the FIRST occurrence of s1 in s
(-1 if s1 does not occur in s).
s.find(s1,n) Returns: index of the first character of the first occurrence of s1 in s
STARTING at position n. (-1 if s1 does not occur in s from this position).
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 numbers; it returns
False otherwise.
s.isalnum() Returns: True if s is not empty and its elements are all letters or numbers;
it returns False otherwise.
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 upper case;
it returns False otherwise (e.g. 'A123' is True but '123' is False).
s.lower() Returns: A copy of s with all letters lower case.
s.upper() Returns: A copy of s with all letters upper case.
List Functions and Methods
Expression
Description
or Method
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.
x.count(y) Returns: the number of times y occurs in x
x.index(y) Returns: index of the FIRST occurrence of y in x
(an error occurs if y does not occur in x).
x.index(y,n) Returns: index of the first occurrence of y in x STARTING at position n
(an error occurs if y does not occur in x).
x.append(y) Adds y to the end of list x.
x.insert(i,y) Inserts y at position i in list x, shifting later elements to the right.
x.remove(y) Removes the first item from the list whose value is y
(an error occurs if y does not occur in x).
The last three list methods are all procedures. They return the value None.
Page 2
CS 1110 Prelim 1 October 16th, 2025
This 90-minute exam has 6 questions worth a total of 100 points. Read over 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; just make sure your name is on every page.
It is a violation of the Academic Integrity Code to look at any exam other than your
own, to look at any other reference material, or to otherwise give or receive unautho-
rized 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
You should not use loops or recursion on this exam. Beyond that, you may use any Python feature
that you have learned in class (if-statements, try-except, lists), unless directed otherwise.
Question Points Score
1 2
2 14
3 20
4 25
5 19
6 20
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
Throughout this exam you will be asked questions about strings and lists. You are expected to
understand how slicing works. In addition, the following functions and methods may be useful.
String Functions and Methods
Expression
Description
or Method
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.count(s1) Returns: the number of times s1 occurs in s
s.find(s1) Returns: index of the first character of the FIRST occurrence of s1 in s
(-1 if s1 does not occur in s).
s.find(s1,n) Returns: index of the first character of the first occurrence of s1 in s
STARTING at position n. (-1 if s1 does not occur in s from this position).
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 numbers; it returns
False otherwise.
s.isalnum() Returns: True if s is not empty and its elements are all letters or numbers;
it returns False otherwise.
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 upper case;
it returns False otherwise (e.g. 'A123' is True but '123' is False).
s.lower() Returns: A copy of s with all letters lower case.
s.upper() Returns: A copy of s with all letters upper case.
List Functions and Methods
Expression
Description
or Method
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.
x.count(y) Returns: the number of times y occurs in x
x.index(y) Returns: index of the FIRST occurrence of y in x
(an error occurs if y does not occur in x).
x.index(y,n) Returns: index of the first occurrence of y in x STARTING at position n
(an error occurs if y does not occur in x).
x.append(y) Adds y to the end of list x.
x.insert(i,y) Inserts y at position i in list x, shifting later elements to the right.
x.remove(y) Removes the first item from the list whose value is y
(an error occurs if y does not occur in x).
The last three list methods are all procedures. They return the value None.
Page 2