-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathex6.py
62 lines (46 loc) · 1.4 KB
/
ex6.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
''' dum = 2
x = "There are %d types of people",dum
# Answer= ('There are %d types of people', 2)
print (x)
x = "There are %d types of people"
binary = "binary"
doNot = "don't"
y = "ZThose who know %s and those who %s." %(binary, doNot)
print (x)
print (y)
#
# The %s specifier converts the object using str(), and %r converts it using repr().
#
# For some objects such as integers, they yield the same result, but repr() is special in that (for types where this is possible) it conventionally returns a result that is valid Python syntax, which could be used to unambiguously recreate the object it represents.
#
# Here's an example, using a date:
#
# >>> import datetime
# >>> d = datetime.date.today()
# >>> str(d)
# '2011-05-14'
# >>> repr(d)
# 'datetime.date(2011, 5, 14)'
print ("I said: %r.")%(x)
print ("I also said: '%s'.") %(y)
hilarious = False
jokeEvaluation = "Isn't that joke funny? ! %r"
w = "This is the left side of ..."
e = "a string with a right side."
print (w+e)
'''
# ###########################
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)
print("I said: %r." % x)
print("I also said: '%s'." % y)
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
print(joke_evaluation % hilarious)
w = "This is the left side of..."
e = "a string with a right side."
print(w + e)