Commit 896e14ed by BellCodeEditor

auto save

parent 73425e1b
#第一关创建函数
def n_w():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit = int(unit)
except:
print("number:")
else:
total.append(unit)
return total
a = n_w()
print(a)
...@@ -5,14 +5,7 @@ def n_w(): ...@@ -5,14 +5,7 @@ def n_w():
if unit== 'q': if unit== 'q':
break break
else: else:
# total.append(unit) total.append(unit)
try: print(total)
unit = int(unit) n_w()
except:
print("请重新输入一个数字")
else:
total.append(unit)
return total
a = n_w()
print(a)
...@@ -2,20 +2,26 @@ def n_w(): ...@@ -2,20 +2,26 @@ def n_w():
total = [] total = []
while True: while True:
unit= input("请输入:") unit= input("请输入:")
if unit== 'q': if unit== 'q' or unit== 'Q':
break break
else: else:
# total.append(unit)
try: try:
unit = int(unit) unit = int(unit)
except: except:
print("请重新输入一个数字") print("请重新输入一个数字")
else: else:
total.append(unit) total.append(unit)
# print(total)
return total return total
a = n_w() # a = n_w()
print(a) # print(a)
#第四关:计算总价 #第四关:计算总价
......
...@@ -35,6 +35,7 @@ p.end_fill() ...@@ -35,6 +35,7 @@ p.end_fill()
p.penup() p.penup()
p.goto(0,50) p.goto(0,50)
p.pendown() p.pendown()
#内切三角形的边长 #内切三角形的边长
len = (math.sqrt(3))*50 len = (math.sqrt(3))*50
p.right(60) p.right(60)
......
# def a():
# total = []
# while True:
# unit= input("请输入:")
# if unit== 'q':
# break
# else:
# total.append(unit)
# print(total)
# a()
try:
age = int(input("年龄:"))
except:
print("要输入整数啊")
else:
if age<18:
print("你可以喝酒哦~")
print("哇哦")
\ No newline at end of file
...@@ -7,8 +7,7 @@ def n_w(): ...@@ -7,8 +7,7 @@ def n_w():
break break
else: else:
total.append(unit) total.append(unit)
print() print()
n_w() n_w()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment