Level 28 Level 30
Level 29

[Quiz] String Processing


17 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
String literals
s1 = "School is cool" is an example of a S.... .......
,
combines strings with one space
+
addition operator - used to find sum of two numbers
print s1[2]
Given s1 = "School is cool" - - how would I output the single letter (character) h?
print s1[-1]
Given s1 = "School is cool!" - - how would I output the single character !?
print len(s1)
print the length of s1 = "school is cool"
print s1[0,5]
print the slice of s1 = "school is cool!" that would only include "school"
print s1[3:]
print da man from the string s1="Dan da man"
s5 = str(number)
convert the string number into a string and place the new string into variable s5
number = int(s5[1:])
convert the string s5 = 123 into an integer in the variable numberthis is used to represent text:
'quotes'
in Python, strings are surrounded by these:
true
t/f: unlike strings, numbers are NOT enclosed in quotation marks
false: python EXPECTS matching quotation marks for strings.
t/f: python does NOT expect matching quotation marks for strings.
is interpreted as the end of that string.
when you start a string definition with a double or single quotation mark, the next double or single quotation mark (respectively), that python encounters is interpreted as this:
sentence = ' She said, "That is a great tasting apple!" '
If you want to include double quotes in a string you can place them inside single quotes as in the following example:
sentence = "That's a great tasting apple!"
If you want to include single quotes in a string, enclose the string in double quotation marks, for example:
by prepending a backslash ( \).
What if you wanted to use both single and double quotes in the same string? At this point you need to escape the offending quotation character with what?