-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex06.py
More file actions
28 lines (21 loc) · 748 Bytes
/
ex06.py
File metadata and controls
28 lines (21 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Exercise 6: Strings and Text
# http://learnpythonthehardway.org/book/ex6.html
# variable definitions can have string formatters, too
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)
print x
print y
# raw formatting of string within single quotes
print "I said: %r" % x
print "I also said: '%s'." % y
# string formatting of string doesn't include ''
# Boolean and string variable definitions
hilarious = False
joke_evaluation = "Isn't that joke so funn?! %r" # value not inserted immediately
print joke_evaluation % hilarious # value inserted here
w = "This is the left side of... "
e = "A string with a right side."
# addition of strings
print w + e