请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
123
返回列表 发新帖
楼主: crossin先生

【Python 第14课】 字符串格式化

[复制链接]

0

主题

0

好友

12

积分

新手上路

Rank: 1

发表于 2018-1-13 23:07:02 |显示全部楼层
from random import randint
answer = randint(1, 100)
print('Guess what number I\'m thinking?')
x = int(input())

while x != answer:
    if x > answer:
        print('%d is too big'% x)
        x = int(input())
    if x < answer:
        print('%d is too small'% x)
        x = int(input())
print('Bingo!%d is the right answer'% x)
回复

使用道具 举报

1

主题

0

好友

23

积分

新手上路

Rank: 1

发表于 2018-4-11 16:32:49 |显示全部楼层
from random import randint
num=randint(1,100)
print('guess what is think')
bingo=False

while bingo== False:
    answer=int(input())

    if int(answer) < num:
        print ('%s is too small'%answer)
        
    if int(answer)>num:
        print('%s is too big!'%answer)

    if int(answer)==num:
        print('BINGO!,%s is the right'%answer)
        bingo=True
回复

使用道具 举报

0

主题

0

好友

48

积分

新手上路

Rank: 1

发表于 2018-5-29 10:43:52 |显示全部楼层
  1. from random import randint

  2. num=randint(23,218)

  3. print('guess what i think?')

  4. bingo = False

  5. while bingo == False:
  6.     a=int(input())
  7.    
  8.     if a >num:
  9.         print('%d is too big'%a)

  10.     if a<num:
  11.         print ('%d is too small'%a)

  12.     if a==num:
  13.         print('excellent!bingo!congratulations!the correct answer is %d'%a)

  14.         bingo=True
复制代码
回复

使用道具 举报

0

主题

0

好友

40

积分

新手上路

Rank: 1

发表于 2020-3-16 20:55:17 |显示全部楼层
手机公众号上是3.0版本的 这个是2.0版本
回复

使用道具 举报

0

主题

0

好友

40

积分

新手上路

Rank: 1

发表于 2020-3-16 21:21:37 |显示全部楼层
zzxomg 发表于 2015-3-12 21:08

你的这个序号怎么加上去的
回复

使用道具 举报

174

主题

45

好友

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

发表于 2020-3-16 22:37:28 |显示全部楼层
哦哦UP 发表于 2020-3-16 21:21
你的这个序号怎么加上去的

回复框里有个 <> 图标,点一下
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

0

主题

0

好友

25

积分

新手上路

Rank: 1

发表于 2021-8-11 11:15:16 |显示全部楼层
zzxomg 发表于 2015-3-12 21:08

饿 看不懂,尝试复制run也失败了。。
回复

使用道具 举报

174

主题

45

好友

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

发表于 2021-8-11 23:52:23 |显示全部楼层
cheer 发表于 2021-8-11 11:15
饿 看不懂,尝试复制run也失败了。。

他发的是py2的代码
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

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

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

GMT+8, 2024-3-29 01:28 , Processed in 0.017888 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部