1 of 11

Lecture 2: Strings and Lists

Autumn 2026

1

Sli.do

#cse163

Questions?

Icebreaker

Watch any good movies or shows recently?

CSE 163

CSE 163: Strings and Lists

​

2 of 11

Announcements

  • Section Check in 1 is due tonight (Friday) on Gradescope at 11:59pm
  • Complete this Intro Survey, due Tuesday, October 6th at 11:59pm
    • Will replace a missed lesson review.
  • Homework 1 released today, due Thursday, October 8 at 11:59pm
  • Make sure you have access to all the course materials
    • Ed, JupyterHub, Gradescope, Canvas
    • If you just enrolled: wait about 24 hours for the rosters to update
  • If you are having trouble running Python files or accessing JupyterHub, please come to office hours or post on Ed.

2

CSE 163: Strings and Lists

​

3 of 11

Today’s Roadmap

  1. Reminder: Course Website
  2. Functions
  3. Strings and Lists
  4. Methods vs. Built-in Functions
  5. Practice Problems!

3

CSE 163: Strings and Lists

​

4 of 11

Reminder: Course Website

  • All course information and resources can be found on the course website.
    • Course schedule and announcements
    • Assignments, lecture recordings, section materials
    • Office Hours
    • Course resources (e.g. JupyterHub, Ed, Gradescope, etc.)
    • …and more
  • Canvas will only be used to display grades, everything else will be on the course website. Please do not contact course staff via Canvas.

4

CSE 163: Strings and Lists

​

5 of 11

Anatomy of a Function

5

def function_name(parameter, ...):

#Function code

return value

​

def keyword

Function name

Optional

parameters

Function code

colon

Indentation

Return statement

CSE 163: Strings and Lists

​

6 of 11

Strings and Lists

  • Strings
    • Text data that has indices for characters
    • Has functions to transform (and return new) strings!
    • String slicing
  • Lists
    • Indexed-sequence (like strings) but can hold values of more data types.
    • The Java equivalent is an ArrayList
  • Documentation
    • Doc-string (““ documentation ””)

6

CSE 163: Strings and Lists

​

7 of 11

Strings and Lists!

7

CSE 163: Strings and Lists

​

8 of 11

Type/Structure Methods vs. Built-in Functions

  • Data types/structures have methods unique to them.
  • Built-in Python functions are not unique to a specific data types/structure

8

s = "oN yOuR lEfT!"

print(s.upper()) #.upper() for strings

print(s.lower()) #.lower() for strings

s = "oN yOuR lEfT!"

c = ["blue", "green", "red", "yellow"]

print(len(s)) # len works for strings!

print(len(c)) # len works for lists!

CSE 163: Strings and Lists

​

9 of 11

Type/Structure Methods vs. Built-in Functions

  • Data types/structures have methods unique to them.
  • Built-in Python functions are not unique to a specific data types/structure

9

s.method(optional,...))

function(s)

Can you think of any other built-in functions?

CSE 163: Strings and Lists

​

10 of 11

10

s = 'on your left!'

# Length

len(s) # 13

​

# Indexing

s[1] # 'n'

s[len(s) - 1] # '!'

​

# Looping

for i in range(len(s)):

print(s[i])

​

for c in s:

print(c)

​

​

l = ['blue', 'red', 'green']

# Length

len(l) # 3

​

# Indexing

l[1] # 'red'

l[len(l) - 1] # 'green'

​

# Looping

for i in range(len(l)):

print(l[i])

​

for word in l:

print(word)

​

​

CSE 163: Strings and Lists

​

11 of 11

Practice Problems!

11

CSE 163: Strings and Lists

​