-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice5-10.py
More file actions
178 lines (111 loc) · 2.73 KB
/
practice5-10.py
File metadata and controls
178 lines (111 loc) · 2.73 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python
# coding: utf-8
# In[9]:
types_of_people = 10
x = f"There are {types_of_people} type of people."
binary = "binary"
do_not = "don't"
y = f"Thos who konw {binary} and those who {do_not}."
print(x)
print(y)
print(f"I said: {x}")
print(f"I also said: '{y}'")
hilarious = False
joke_evaluation = "Isn't the joke so funny?! {}"
print(joke_evaluation.format(hilarious))
w = "This is the left side of..."
e = "a string with a right side"
print(w + e)
# In[10]:
w = "This is the left side of..."
e = "a string with a right side"
print(w + e)
# In[11]:
hilarious = False
joke_evaluation = "Isn't the joke so funny?! {}"
print(joke_evaluation.format(hilarious)) #.format() one type of format and {} is ocupation symbol
# In[13]:
print("mary had a little lamb.")
print("Its fleece was white as {}.".format('snow'))
print("And everywhere that Mary went.")
print("." * 10) # what'd that do?
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "s"
end5 = "e"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print(end1 + end2 + end3 + end4 + end5 + end6, end=' ')#this ", end=' '" look like mean to connect two sentences in two lines
print(end7 + end8 + end9 + end10 + end11 + end12)
# In[14]:
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "s"
end5 = "e"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print(end1 + end2 + end3 + end4 + end5 + end6)
print(end7 + end8 + end9 + end10 + end11 + end12)
# In[25]:
print("a", end = ' ')
print("b")
# In[29]:
formatter = "{} {} {} {}"
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"Try your",
"Own text here",
"Mabey a poem",
"Or a song about fear"
))
# In[30]:
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug "# /n 隔行
print("Here are the days: ", days)
print("Here are the month: ", months)
print("""
There's something going on here.
with the three double-quotes.
we'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""") # """连接分行
# In[32]:
print("""
There's something going on here.
with the three double-quotes.
we'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""")
# In[33]:
tabby_cat = "\tI'm tabbled in." # \t 制表符
persian_cat = "I'm split\non a line"
backslash_cat = "I'm \\a\\cat." # \\ 显示\(进行转义)
fat_cat = """
I'll do a list:
\t* cat food
\t* Fishes
\t* Catnip\n\t* Grass
""" # \n 换行
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)
# In[38]:
print("\\")
print("r\ar")
# In[ ]: