设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: iamocean
打印 上一主题 下一主题

【Python 第8课】while

[复制链接]

0

主题

1

好友

40

积分

新手上路

Rank: 1

33#
发表于 2016-3-22 09:50:20 |只看该作者
为什么我输入一个值  么就无限刷屏输出  too big
回复

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

32#
发表于 2016-3-14 12:41:42 |只看该作者
suanshine 发表于 2016-3-14 10:00
我想请问一下,我用的是3.5,然后我这样输入
num = 10
print("Guess what I think?")

python3 的input获得的是一个字符串,相当于2的raw_input
所以跟数字比较前要做转换
比如写成
answer=int(input())
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

0

主题

0

好友

4

积分

新手上路

Rank: 1

31#
发表于 2016-3-14 10:00:01 |只看该作者
我想请问一下,我用的是3.5,然后我这样输入
num = 10
print("Guess what I think?")
answer = input()

if answer < num:
    print('too small!')

if answer > num:
    print('too big!')

if answer == num:
    print ('BINGO!')
得到的结果是    if answer < num:
TypeError: unorderable types: str() < int()为什么啊?
C:\Users\sunshine\Desktop
回复

使用道具 举报

0

主题

1

好友

273

积分

中级会员

Rank: 3Rank: 3

30#
发表于 2015-12-19 00:07:10 |只看该作者
好棒!

Python5.png (3.94 KB, 下载次数: 365)

Python5.png

回复

使用道具 举报

0

主题

0

好友

10

积分

新手上路

Rank: 1

29#
发表于 2015-10-13 20:10:59 |只看该作者
while内套语句必须带有让while停止运行的语句
      
回复

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

28#
发表于 2015-8-16 15:44:16 |只看该作者
Hanami 发表于 2015-8-13 21:27
先生问一下,bingo=True,这一行有什么作用呢
num = 18
print'Guess what i think'

你这个程序没法结束
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

0

主题

0

好友

10

积分

新手上路

Rank: 1

27#
发表于 2015-8-13 21:27:29 |只看该作者
先生问一下,bingo=True,这一行有什么作用呢
num = 18
print'Guess what i think'
a=False

while a==False:
    answer=input()

    if answer<num:
        print'too small!'

    if answer>num:
        print'too big!'

    if answer==num:
        print'you re right!'

我这样写,运行后,感觉和加没加那一行代码没什么区别
回复

使用道具 举报

0

主题

0

好友

215

积分

中级会员

Rank: 3Rank: 3

26#
发表于 2015-4-20 21:28:52 |只看该作者
手绘流程图一点都不渣啊
回复

使用道具 举报

0

主题

0

好友

6

积分

新手上路

Rank: 1

25#
发表于 2015-4-13 22:33:45 |只看该作者
crossin先生 发表于 2015-4-13 19:38
缩进没对齐

thanks!
回复

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

24#
发表于 2015-4-13 19:38:45 |只看该作者
kelvin 发表于 2015-4-13 13:16
crossin先生你好,最后一行 bingo=True报错,怎么回事啊?
情况如图。

缩进没对齐
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-17 11:34 , Processed in 0.019464 second(s), 23 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部