<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 IST256 Lesson 06
Strings
Zybook Ch6
P4E Ch6
Links
Participation
Step1:  A. 8
B. 7
C. Error (NameError)
D. 6  
BROKEN!!!
Vote Now
Step2:  A. 3
B. 4
C. 6
D. 10  
Vote Now
Step3:  A. 8
B. 6
C. 4
D. 2  
Vote Now
Step4:  A. 'Miie'
B. 'MKKE' 
C. 'MIIE'
D. 'Mkke'  
Vote Now
<ASSISTANT_TASK:>
Python Code:
def doit(a,b):
    return a+b
x = 4
y = 3
z = doit(x,x)
print(z)
Explanation: IST256 Lesson 06
Strings
Zybook Ch6
P4E Ch6
Links
Participation: https://poll.ist256.com <= AZURE IS DOWN!
Ask in your Zoom Chat
Agenda
Homework 05
Quick Review of the Solution
Strings
- Strings are immutable sequence of characters.
- Index and Slice notation for retrieving sub-strings.
- Built-in string functions to perform operations on strings.
- Techniques for parsing and tokenizing string data.
- How to sanitize input with string functions.
FEQT (Future Exam Questions Training) 1
What is the output of the following code?
End of explanation
x = int(input())
z = 0
for i in range(x):
    z = z + i
print(z)
Explanation: A. 8
B. 7
C. Error (NameError)
D. 6  
BROKEN!!!
Vote Now: https://poll.ist256.com
FEQT (Future Exam Questions Training) 2
Given the following input 4 what is the output?
End of explanation
def x(a,b):
    return b
w = int(input())
y = 2
for i in range(w):
    z = x(i,y)
    t = x(y,i)
print(t)
Explanation: A. 3
B. 4
C. 6
D. 10  
Vote Now: https://poll.ist256.com
FEQT (Future Exam Questions Training) 2
Given the following input 4 what is the output?
End of explanation
x = "Mike"
y = x.upper().replace("I","K")
y
Explanation: A. 8
B. 6
C. 4
D. 2  
Vote Now: https://poll.ist256.com
Strings are Sequences of Characters
Strings are index able sequences of characters. 
The characters inside the string are immutable.
Example:
<font color='green'> Name = 'Fudge'</font>
<font color='green'>len(Name) == 5</font>
Immutable means we can’t change part of it:
<font color='red'>Name[1] = 'u'</font>
Slice Notation
Slice Notation is used to extract a substring.
Examples:
<font color='green'>Name[0:2] == 'Fu'</font>
<font color='green'>Name[2:5] == 'dge'</font>
<font color='green'>Name[:4] == 'Fudg'</font>
<font color='green'>Name[:] == 'Fudge'</font>
<font color='green'>Name[1:-1] == 'udg</font>
Check Yourself: String Slices 1
Match each string slice to its value for this string:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x ='orange'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x[1:6]  
&nbsp;&nbsp; A. 'ang'  
   &nbsp;&nbsp; B. 'rang' 
   &nbsp;&nbsp; C. 'range'
Vote Now: https://poll.ist256.com
Check Yourself: String Slices 2
Match each string slice to its value for this string:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x ='orange'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x[2:-1]    
&nbsp;&nbsp; A. 'ang'  
   &nbsp;&nbsp; B. 'rang'   
   &nbsp;&nbsp; C. 'range'  
Vote Now: https://poll.ist256.com
String functions:
Built In String Functions: 
    https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str 
dir(str)
help(str.upper)
The Python String Library:
    https://docs.python.org/3/library/string.html
You must import String before you can use them.
Watch Me Code 1
Yes or No?
Write a function to accept a variety of inputs as "yes" or "no"
<font color='green'> "yes" <span>&#8594;</span>  "y", "Y", "YES", "Yes" etc… </font>
<font color='green'>"no" <span>&#8594;</span> "n", "N", "NO", "No", etc…</font>
Check Yourself: Code Trace 1
What is the value of the variable y on line 2?
End of explanation
text = "This is mike"
for word in text.split("i"):
    print(word[1], end='')
Explanation: A. 'Miie'
B. 'MKKE' 
C. 'MIIE'
D. 'Mkke'  
Vote Now: https://poll.ist256.com
String Tokenization and Parsing
Tokenization  is the process of breaking up a string into words, phrases, or symbols. 
Tokenize a sentence into words.
"mike is here" becomes  ['mike','is','here']
Parsing is the process of extracting meaning from a string. 
Parse text to a numerical value or date.
int('45') becomes 45
Watch Me Code 2
Given a string of digits: e.g. '12 45 90'
1. Tokenize into individual strings
2. Parse into integers
3. Add them up!
Check Yourself: Code Trace 2
What is the output of this program?
End of explanation
<END_TASK>