python中大于多少小于怎么表示_Python While语句大于/小于符号
print ("Hello, this is a change return program, coded by A person")
cost = float(input("How much did the object cose (in £s, eg 0.50 for 50p)?"))
given = float(input("How much money did you pay (in the same format)?"))
change = given - cost
twentypounds = 0
tenpounds = 0
fivepounds = 0
twopounds = 0
onepound = 0
fiftypennies = 0
twentypennies = 0
tenpennies = 0
fivepennies = 0
twopennies = 0
onepenny = 0
print(change)
while change >= 20:
change = change - 20
twentypounds + 1
print(twentypounds)
while change >=10 and <20 :
change = change - 10
tenpounds + 1
print(tenpounds)
while change 10> and >= 5:
change = change - 5
fivepounds + 1
print(fivepounds)
while change <5 and >= 2:
change = change - 2
twopounds + 1
print(twopounds)
while change <2 and >= 1:
change = change - 1
onepound + 1
print(onepound)
while change <1 and >= 0.5:
change = change - 0.5
fiftypennies + 1
print(fiftypennies)
while change <0.5 and >= 0.2:
change = change - 0.2
twentypennies + 1
print(twentypennies)
while change <0.2 and >= 0.1:
change = change - 0.1
tenpennies + 1
print(tenpennies)
while change <0.1 and >= 0.05:
change = change - 0.05
fivepennies + 1
print(fivepennies)
while change <0.05 and >= 0.02:
change = change - 0.02
twopennies + 1
print(twopennies)
while change <0.02 and >= 0.01:
change = change - 0.01
onepennies + 1
print(onepenny)
print("The Change Value is now:", change, " This is for debugging only")
twenty_pounds = twentypounds * 20
ten_pounds = tenpounds * 10
five_pounds = fivepounds * 5
two_pounds = twopounds * 2
one_pound = onepound * 1
fifty_pennies = (fiftypennies * 50) / 100
twenty_pennies = (twentypennies * 20) / 100
ten_pennies = (tenpennies * 10) / 100
five_pennies = (fivepennies * 5) / 100
two_pennies = (twopennies * 2) / 100
one_penny = (onepenny * 1) / 100
total_change = twenty_pounds + ten_pounds + five_pounds + two_pounds + one_pound + fifty_pennies + twenty_pennies + ten_pennies + five_pennies + two_pennies + one_penny
print("Your Total Change is:", total_change)
当它工作时,它只返回0.0次多次,现在一直给我无效的语法,我试图交换标志,然后还有数字,但是无法解决任何问题,任何想法如何解决这个问题?
新代码:(仍然没有工作,虽然现在没有语法错误,只返回0(尽管数字在第4行有所变化)
print ("Hello, this is a change return program, coded by A person")
cost = float(input("How much did the object cose (in £s, eg 0.50 for 50p)?"))
given = float(input("How much money did you pay (in the same format)?"))
change = given - cost
twentypounds = 0
tenpounds = 0
fivepounds = 0
twopounds = 0
onepound = 0
fiftypennies = 0
twentypennies = 0
tenpennies = 0
fivepennies = 0
twopennies = 0
onepenny = 0
print(change)
while change >= 20:
change = change - 20
twentypounds + 1
print(twentypounds)
while change >= 10 and change < 20:
change = change - 10
tenpounds + 1
print(tenpounds)
while change > 10 and change >= 5:
change = change - 5
fivepounds + 1
print(fivepounds)
while change < 5 and change >= 2:
change = change - 2
twopounds + 1
print(twopounds)
while change < 2 and change >= 1:
change = change - 1
onepound + 1
print(onepound)
while change < 1 and change >= 0.5:
change = change - 0.5
fiftypennies + 1
print(fiftypennies)
while change < 0.5 and change >= 0.2:
change = change - 0.2
twentypennies + 1
print(twentypennies)
while change < 0.2 and change >= 0.1:
change = change - 0.1
tenpennies + 1
print(tenpennies)
while change < 0.1 and change >= 0.05:
change = change - 0.05
fivepennies + 1
print(fivepennies)
while change < 0.05 and change >= 0.02:
change = change - 0.02
twopennies + 1
print(twopennies)
while change < 0.02 and change >= 0.01:
change = change - 0.01
onepennies + 1
print(onepenny)
print("The Change Value is now:", change, " This is for debugging only")
twenty_pounds = twentypounds * 20
ten_pounds = tenpounds * 10
five_pounds = fivepounds * 5
two_pounds = twopounds * 2
one_pound = onepound * 1
fifty_pennies = (fiftypennies * 50) / 100
twenty_pennies = (twentypennies * 20) / 100
ten_pennies = (tenpennies * 10) / 100
five_pennies = (fivepennies * 5) / 100
two_pennies = (twopennies * 2) / 100
one_penny = (onepenny * 1) / 100
total_change = twenty_pounds + ten_pounds + five_pounds + two_pounds + one_pound + fifty_pennies + twenty_pennies + ten_pennies + five_pennies + two_pennies + one_penny
print("Your Total Change is:", total_change)
现在代码只打印:(更改是正确的)0.0,0.0,0.0等...
代码现在有效,感谢您的回答!
python中大于多少小于怎么表示_Python While语句大于/小于符号相关推荐
- python中else是指什么意思_python中elif什么意思?
原标题:python中elif什么意思? else和elif语句也可以叫做子句,因为它们不能独立使用,两者都是出现在if.for.while语句内部的.else子句可以增加一种选择:而elif 子句则 ...
- python中demo函数是什么意思_Python学习09:定义函数
这次我们在上一次创建的com.second.function下创建Demo02.py 在Python中,定义一个函数要使用 def 语句,依次使用函数名.括号.括号中的参数和冒号 : ,然后在缩进块中 ...
- python中的pass是空语句一般用作占位语句_1、python基本语法
1.python基本语法 1.1. pycharm中字符集,单行,多行注释 #-*- codeing = utf-8 -*- [email protected] : 2020/6/6 15:17 [e ...
- python中用于获取当前目录的是_python中获得当前目录和上级目录的实现方法
python中获得当前目录和上级目录的实现方法 获取当前文件的路径: from os import path d = path.dirname(__file__) #返回当前文件所在的目录 # __f ...
- python中find函数运算结果类型_Python 运算符与数据类型
Python 运算符 运算符用于执行程序代码运算,会针对一个以上操作数项目来进行运算,在Python中运算符大致可以分为7种类型:算术运算符.比较运算符.赋值运算符.逻辑运算符.位运算等,下面的例子将 ...
- python中的ture是常量吗_python中的true是什么
Python的布尔类型有两个值:True和False(注意大小写要区分,首字母大写,注意) 0.逻辑运算符:a.与:and(两个都为True,结果才为True) b.或:or(只要一个为True,则为 ...
- python中属于有序序列的有_Python中的有序序列有哪些
Python中的有序序列有哪些 list.tuple以及str都是有序序列,和后面两者不同的是list是个可变对象,tuple和str则是不可变对象.主要讲的就是这三种的有序序列的一些方式.方法效果L ...
- python中的选择最高的成绩_python 输入学生成绩 若成绩在90、流程图_Python习题选编...
<Python习题选编>由会员分享,可在线阅读,更多相关<Python习题选编(20页珍藏版)>请在人人文库网上搜索. 1.Python习题选编华东师大信息学院计算中心一程序结 ...
- python中if有多个条件_Python中if有多个条件处理方法
Python中if有多个条件处理方法 Python中if有多个条件怎么办 python中if有多个条件,可以使用and.or.elif关键字来连接. Python 编程中 if 语句用于控制程序的执行 ...
- python中math.ceil是什么意思_python中的数字取整(ceil,floor,round)概念和用法
python中的数学运算函数(ceil,floor,round)的主要任务是截掉小数以后的位数.总体来说 就是取整用的.只是三者之间有微妙的区别: floor() :把数字变小 ceil() : 把数 ...
最新文章
- Java一个线程能否结束另一个永不停止的线程
- 独家 | 2018年Analytics Vidhya上最受欢迎的15篇数据科学和机器学习文章
- 大厂围猎春招,年轻人却卸甲出逃
- 软件工程师技术面试一面真题
- java小数转换成百分数_在java中如何把小数转化成百分数
- 前端学习(3216):总结state
- win7电脑共享硬盘分区的方法
- 如何使用 fstream 类进行文件的 I/O 处理
- countdownlatch的使用详解(好懂!!)
- pojo类中的布尔类型的变量为什么不能加is
- websocket.onmessage回调没反应_等待A股暴跌回调补四缺口倒计时第二十四天——8月19日总结...
- 宝塔部署node项目_SFF一站式node服务管理平台实践
- sql 查询 当不想查出记录时候采用的方法
- 常见HTTP状态码大全
- 思维导图MindManager2022版下载安装(无序列号)
- react与mobx搭配时如何缓存mobx的数据(刷新之后保存状态)
- TIL: 申请一个30天的体验版本的 Salesforce Consumer Goods Cloud Org
- C语言编程入门新手学习精华:这样学习C语言最有效
- 序列生成与滑动平均滤波
- Windows 10 1809 MSDN 版本下载 ed2k 链接