Commit a170bd5c by BellCodeEditor

auto save

parent 7eaed43a
Showing with 65 additions and 0 deletions
x = int(input("总共带了多少钱"))
a = int(input("乒乓球拍的价格"))
b = int(input("乒乓球的价格"))
print("乒乓球的数量是:",int((x-a)/b))
from turtle import *
color("black")
speed(5)
fillcolor("red")
begin_fill()
goto(0,-100)
pendown()
circle(100,180)
left(90)
forward(100)
end_fill()
goto(0,100)
right(90)
fillcolor("yellow")
begin_fill()
circle(100,180)
end_fill()
penup()
goto(0,0)
hideturtle()
done()
import turtle
pen = turtle.Pen()
\ No newline at end of file
def new_input():#定义函数
total = []#建立空列表
while True:#无限循环
unit = input('请输入(q退出):')#获取输入内容
if unit == 'q':#条件判断
break
else:#否则
try:#try语句检测BUG
unit = int(unit)
except:
print("请重新输入一个数字")
else:
total.append(unit)
finally:
print("=====================")
return total#return返回;返回列表
def sum(money):#调用函数
count = 0#建立新变量,用于储存数字
for i in money:#for循环遍历
count = count + i#将列表当中的每一个数字依次添加到count中
return count#返回最终的值
price = new_input()#将自定义函数new_input()的返回值重新赋值
pay = sum(price)#求和
print("您一共消费了" + str(pay) + "元!扫码还是现金呢?")#输出最终结果
\ No newline at end of file
import func
# 调用自定义的输入函数,实现分数输入的功能
data = func.new_input()
# 调用自定义的求和函数,计算需要支付的总价
score = func.sum(data)
print("这位选手的总分数为:"+str(score))
\ No newline at end of file
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