input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'
今天学习python基础—分支与循环,接触到了if。在练习一个if语句的时候,出现了错误。
题目是: 根据分数划分成四个级别:优秀、良好、及格、不及格,分数是72:
grade = 72
if grade >= 90:
print('优秀')
elif grade >=70:
print('良好')
elif grade >=60:
print('及格')
else:
print('不及格')
grade = input('请输入你的分数:')
if grade >= 90:
print('优秀')
elif grade >=70:
print('良好')
elif grade >=60:
print('及格')
else:
print('不及格')

报错原因是:input()输入的内容是一个字符串,字符串跟整型数值进行比较,类型不匹配
修改方法:

input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'的更多相关文章
- Python报错TypeError: '<' not supported between instances of 'str' and 'int'
n = input() if n>=100:print(int(n)/10) else:print(int(n)*10) 报错内容: Traceback (most recent call la ...
- python报错:not supported between instances of 'str' and 'int'
not supported between instances of 'str' and 'int' : 意思就是字符串不能和int类型的数值比较
- TypeError: '<' not supported between instances of 'str' and 'int'
<不支持str实例和int实例之间的对比 birth是str类型 2000是int类型 所以无法对比,报错 birth = input('birth: ') if birth < 2000 ...
- python的强制转换(当出现 not supported between instances of 'str' and 'int' 的错误时)
当我们编程时,有时会出现如下错误:TypeError: '>' not supported between instances of 'str' and 'int' 如下图: 这是因为input ...
- python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Command "python setup.py egg_info" failed with error code 1 in
pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl ...
- 解决pip安装时出现报错TypeError unsupported operand type(s) for -= 'Retry' and 'int'
1.参考 https://stackoverflow.com/questions/42610545/typeerror-unsupported-operand-types-for-retry-and- ...
- PyCharm启动报错 TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’ 解决
这个提示大概是说:"类型错误:不支持操作类型为字符串和字符串",直接把两个字符串(BASE_DIR = os.path.dirname(os.path.dirname(os.pat ...
- firefox浏览器中使用vux的x-input报错TypeError: _this3.$refs.input.scrollIntoViewIfNeeded is not a function
最近做公众号项目,想着统一风格,所以决定使用vux. 在调试时发现,只要鼠标点击x-input输入框,就会报错 TypeError: _this3.$refs.input.scrollIntoView ...
- [转载]UEditor报错TypeError: me.body is undefined
本文转载来自:UEditor报错TypeError: me.body is undefined 今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.bo ...
随机推荐
- HDU 4871 Shortest-path tree
先用dijkstra把最短路树建出来,然后就是树的质心分治了. 经过k个点的路径,要么全在子树上,要么经过根结点,因此可以分治. 如果分治的时候选点不好会变成O(n^2),比较极端的情况是比如树是一条 ...
- UESTC 757 棋盘
虽然是水题,但是还是很interesting的.(大概就是我最晚出这个题了... 博弈感觉就是靠yy能力啊.这题是对称性. 最后的必败态是白色格子对称的,一旦对称形成,对手怎么选,跟随就好,对手无法摆 ...
- ios视图层次结构
原文:http://blog.csdn.net/xingboss3/article/details/7890238 UIView表示屏幕上的一块矩形区域,它在App中占有绝对重要的地位,因为IOS中几 ...
- hihoCoder 网络流四·最小路径覆盖
题面带解释 hihoCoder感觉很好. 网络流的精华就是建图 #include<cstdio> #include<iostream> #include<algorith ...
- System.Web.UI.Page
mdsn:点击查看此类介绍 git: 点击查看封装方法 消息弹框,消息弹框跳转,自定义脚本信息 定义:表示一个从托管 ASP.NET Web 应用程序的服务器请求的 .aspx 文件(也称为 ...
- Python——并发编程
开始说并发编程之前,最好有一定的底层知识积累,这里我把需要的知识总结了一下,如果看下面的有不理解的可以看一下:https://www.cnblogs.com/kuxingseng95/p/941820 ...
- AMD、CMD、CommonJs和ES6对比
一.AMD(异步模块定义) AMD(异步模块定义)是RequireJS在推广过程中对模块定义的规范化产出.AMD是一个概念,RequireJs是对这个概念的实现.比如javascript语言是对ECM ...
- .NET中微软实体框架的数据访问方法
介绍 本文的目的是解释微软的实体框架提供的三种数据访问方法.网上有好几篇关于这个话题的好文章,但是我想以一个教程的形式更详细地介绍这个话题,这个教程对于开始学习实体框架及其方法的人来说是个入门.我们将 ...
- Hibernate进阶学习3
Hibernate进阶学习3 测试hibernate的多表关联操作(一对多,多对一,多对多) 表之间的关系主要在类与元数据配置文件中体现 package com.hibernate.domain; i ...
- jQuery检测判断复选框是否被选中了的几种方法
方法一:if ($("#checkbox-id")get(0).checked) { // do something} 方法二:if($('#checkbox-id').is ...