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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
| """ 这里写的是2023-09-12的复习 学到了(字符串、+、格式化、输入输出、分支语句 """ import random
str01= "jack"
str02= 'lucky'
str03= """people"""
print(str01,str02,str03)
print("Hello" + "World") print(str01 + str02 + str03)
price = 11.9823 print("单价:%0.1f" %price) count = 5 print("单价:%.2f 数量:%d 总价:%.2f" %(price,count,(price * count)))
print(f"单价:{price} 数量:{count} 总价:{price * count}")
name = input("请输入你的姓名:") age = input("请输入你的年龄:") print(type(name),type(age))
age = int(input("请你再次输入个年龄:")) print(type(age))
text = random.randint(1,10) if int(input("请输入第一次猜测数:")) == text: print("第一次正确了") elif int(input("第一次错误,请进行第二次猜测:")) == text: print("第二次正确") elif int(input("前两次都错了,这是最后的机会:")) == text: print("最后一次正确") else: print(f"没有一次正确,正确的是:{text}")
str01= "jack"
str02= 'lucky'
str03= """people"""
print(str01,str02,str03)
print("Hello" + "World") print(str01 + str02 + str03)
print('he said:"let us go"') print("he said:let'us go") print("he said: \"let\'s go") name= "足球" price= 20.88 count = 4 sum_price = price * count
print("今天买了 %d 个 %s 每个%f 元,总计:%f元" %(count,name,price,sum_price))
print("今天买了%d个%s,每个%.2f元,总计:.2f元" %(count,name,price,sum_price))
print("今天买了:%s" %name)
msg = "单价:%f" %price print(msg)
print(f"今天买了{count}个{name}每个{price},总计:{price*count}")
name= "足球" price= 20.88 count = 4 sum_price = price * count
print("今天买了 %d 个 %s 每个%f 元,总计:%f元" %(count,name,price,sum_price))
print("今天买了%d个%s,每个%.2f元,总计:.2f元" %(count,name,price,sum_price))
print("今天买了:%s" %name)
msg = "单价:%f" %price print(msg)
print(f"今天买了{count}个{name}每个{price},总计:{price*count}")
name = input("姓名:") chinese = input("语文成绩:") math = input("数学成绩:") english = input("英语成绩:")
chinese = float(chinese) math = float(math) english = float(english)
print("姓名:%s 语文:%0.1f 数学:%0.1f 英语:%0.1f 总分:%0.1f 平均分:%.2f" %(name,chinese,math,english,(chinese+math+english),(chinese+math+english)/3))
print(f"姓名:{name} 语文:{chinese} 数学:{math} 英语:{english}"+f"总分:{chinese+math+english}"+f"平均分:{(chinese+math+english)/3}")
name = input("姓名:") chinese = input("语文成绩:") math = input("数学成绩:") english = input("英语成绩:")
chinese = float(chinese) math = float(math) english = float(english)
print("姓名:%s 语文:%0.1f 数学:%0.1f 英语:%0.1f 总分:%0.1f 平均分:%.2f" %(name,chinese,math,english,(chinese+math+english),(chinese+math+english)/3))
print(f"姓名:{name} 语文:{chinese} 数学:{math} 英语:{english}"+f"总分:{chinese+math+english}"+f"平均分:{(chinese+math+english)/3}")
if input("user:") == "jack": if input("password:") == "password": print("log in succer") else: print("error") else: print("user is error")
mouth = input("请输入月份:") mouth = int(mouth) if mouth ==12 or mouth ==1 or mouth ==2: print("yuru") elif mouth ==3 or mouth ==4 or mouth ==5: print("haru") elif mouth ==6 or mouth ==7 or mouth ==8: print("natsu") elif mouth ==9 or mouth ==10 or mouth ==11: print("aki") else:print("error")
import random
text = random.randint(1,10) if int(input("请输入第一次猜测数:")) == text: print("第一次正确了") elif int(input("第一次错误,请进行第二次猜测:")) == text: print("第二次正确") elif int(input("前两次都错了,这是最后的机会:")) == text: print("最后一次正确") else: print(f"没有一次正确,正确的是:{text}")
age=int(input("请输入年龄:")) while age<=23: print("上学",end=' ') age+=1 print("结束")
num=1 while num<=10: print(f"{num}" ,end=' ') num+=1 print("结束")
i=1 j=1 while i<=9: while j<=9: print(i,"*",j,"=",i*j,"\n") i+=1 j+=1
import random
text=random.randint(1,100)
x = int(input("请输入猜测数字:"))
count = 1 while text!=x: if text < x: print("big") count += 1 else: print("small") count += 1 x = int(input("请输入猜测数字:")) print(f"bingo,用了{count}次")
day = 1 while day <= 7: print(f"一周的第{day}天") count = 1 pirce=int(input("输入个想要的公里数:")) while count<=pirce: print(f"\t跑了{count}公里", end=' ') print("\t") count +=1 day += 1 print() print("跑步结束")
day = 1 while day <= 7: print(f"一周的第{day}天") count = 1 pirce=int(input("输入个想要的公里数:")) while count<=pirce: print(f"\t跑了{count}公里", end=' ') print("\t") count +=1 day += 1 print() print("跑步结束")
word=input("输入一个句子:") count=0 for ch in word: print(f"{ch}" ,end=' ') if (f"{ch}")=="e": count +=1 print(f"有{count}个e")
word=input("输入一个句子:") count=0 for ch in word: print(f"{ch}" ,end=' ') if (f"{ch}")=="e": count +=1 print(f"有{count}个e")
for num in range(2,51,2): print(f"{num}", end=' ') print("结束")
for num in range(1,51): if num % 2 == 0: print(f"{num}", end=' ') print("结束")
for i in range(1,10): for j in range(1,10): print(f"{j}*{i}={j*i}\t", end=' ') print()
for i in range(1,10): for j in range(1,i+1): print('{}x{}={}\t'.format(j,i,i*j),end='') print()
for k in range(1,11): print(f"{k}", end=' ') print() print(k)
k=0 for k in range(1,11): print(f"{k}" ,end=' ') print() print(k)
|