Indexing/Slicing
In/Immutability
Strings & For Loops
String Methods
Misc
100

"joe"[0]

"j"

100

What does it mean to be immutable

Cannot be changed. If you want to make a change you need a new variable or to lose the old value

100

What are the two ways you can iterate over a loop?

By element or character

By index or range

100

Which method checks for extra spaces at the start and end?

.strip()

100

How do you change a value into a string 

str(variable)

200

"Sarah"[1:4]

"ara"

200

"abc" in "abc"

True

200

Write the two loop headers for the two ways of writing a loop with a string. Assume the variable "name" is a string.

for letter in name:

for i in range(len(name)):

200

What does swapcase do?

uppercase letters become lowercase letters

lowercase letters become uppercase letters

numbers and characters stay the same

200

How do you identify a string?

" " or ' '

300

"Joseph"[100]

error

300

"abc" in "A"

False

300

word = "sad"

for x in range(len(word)):

     print(str(x)+ word[x])

Index concatenated with the character

0s

1a

2d

300

What is the difference between a and b?

a.find(b)

A is the string you are looking through, b is the string you are trying to find
300

len("abcdefg")

7
400

"Mazen"[1:100]

"azen"

400

"ace" in "abcefgh"

Falsse

400

word = "abcdefg"

for letter in word:

     if letter in "abc":

          print(1)

     else:

          print(letter)

if letters a, b, or c, print 1 otherwise print the letter 

1

1

1

d

e

f

g

400

"a".swapcase().lower().upper().islower()

False

400

Why is user input being a string beneficial?

User can enter anything then it can be changed

- math, into a number, try except

- words, change capitalization, loop to check

500

"abcdefghijklmnop"[5:][1]

"g"

500
Prove the string "hi" is immutable

"hi"[0] = "H" produces an error

500

loop through the string "hello". If there is a vowel, print the index, otherwise print the letter

x = "hello"

for i in range(len(x)):

     if x[i] in "aeiou":

          print(i)

     else:

          print(x[i])

500

When would you use .isupper() and not .upper()

Checking if uppercase, and want to use in an if statement

500

How do you add a new line or tab in your string?

/n new line

/t tab