🖨️

Check.It
9.1 Strings1
Intro. Python : 09.Strings

There are 10 kinds of people in this world:
those who understand binary
those who don't
and those who weren't expecting a base 3 joke



Python "Cheat Sheet"
INSTRUCTIONS:

This might help!

1.  
word = "creative"
print(word[4])

2.  
word = "creative"
word2 = word.capitalize()
same = word2[2] == word[len(word) - 1]
print(same)

3.  
word = "creative"
the_sum = word.find("q") + word.find("e")
print(the_sum)

4.  
word = "cats and dogs and dogs and cats"
fyi  =  012345678901234567890123456789012
the_sum = word.find("cats", 5) + word.find("dogs", 4)
print(the_sum)

5.  
word = ""
for ltr in "code":
    word += ltr * 2
print(word)

Use this for the next few problems:

style = "creative"

6.  
print(style[2:4])

7.  
print(style[:3])

8.  
print(style[-2:])

style = "creative"

9.  
print("eat" in style)

10.  
print(style.find("eat"))

11.  
print(style.find("it"))

style = "creative"

12.  
print(style[style.find("e") + 1:])

13.  
state        = "mississippi"
fyi_digits   =  01234567890
print(state.rfind("p"))

14.  
state        = "mississippi"
fyi_digits   =  01234567890
slicey       = state[3:8]
print(slicey[2])

15.  
state        = "mississippi"
fyi_digits   =  01234567890
print(state[-4:-1][2])

16.  Arrange the blocks so that this function takes two words of the same length as arguments and returns a string with just the characters that it finds in both words that are in the same spot (index) as each other

EXAMPLE: if you send it 'hello' and 'hilly' it should return 'hll

😲 ONE of the blocks doesn't get used!

CLICK to move to next open slot on right
DRAG to a specific slot
CLICK to move to next open slot on this side
DRAG to new spot or left side
01  def common_ones(word1, word2):
1
02          if word1 == word2:
2
03      for i in word1:
3
04      return new_string
4
05          new_string += word1[i]
5
06      for i in range(len(word1)):
6
07              return new_string
08              new_string += word1[i]
09      new_string = ''
10          if word1[i] == word2[i]:

17.  What do a, b, and c need to be for this code to print LE HOOL ?
Write your values for a, b, and c with a comma between:
school     = 'CONCORD-CARLISLE HIGH SCHOOL'
fyi_digits =  0123456789012345678901234567
print(school[a:b] + school[c:])




Not done yet?
• You DO NOT have to 'save' while you are working (your work auto-saves to THIS BROWSER's cache)
• If you click this button, it will send your current progress to your teacher,
but they will know you are not done yet


Check.It ©Anthony Beckwith 2019-2024