Slides 3
Slides 3
Section 2
Chapter 2
• Output
• sep and end arguments in print()
• Escape sequences
• f-strings
• Lab
String Literals
• The most common types of data processed by Python are strings and numbers.
• Print a string
• Quotation marks not included in display
12
© 2016 Pearson Education, Ltd. All rights reserved.
Indexing and Slicing Out of Bounds
• Python does not allow out of bounds indexing for individual
characters of strings
• Does allow out of bounds indices for slices
• Print function uses string consisting of one space character as the default
separator
• Once can change the ending operation with the end argument.
• f-strings
#Step 2: Find the index of the first letter of the user-entered word in the reference string
"ABCDEFGHIJKLMNOPQRSTUVWXYZ”.
#Step 3: Add the number of shifts to the above index to get the new index.
# Notice that in some cases, the sum would exceed 26. Use the modulo operator %.
#Repeat the above steps for the remaining letters in the word.