设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
123
返回列表 发新帖
楼主: crossin先生
打印 上一主题 下一主题

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

[复制链接]

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

21#
发表于 2016-12-20 14:06:45 |只看该作者
ponber 发表于 2016-12-19 21:05
from random import randint
num1=randint(1,50)

可以的。
你可以再尝试用while循环,把它写成一个可以一直猜的程序
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

0

主题

0

好友

34

积分

新手上路

Rank: 1

22#
发表于 2016-12-20 19:33:44 |只看该作者
from random import randint
m=0
while m==0:
    num=randint(1,50)
    bingo=False
    aa='Your answer '
    print'Just guess and guess again,don\'t stop!\nDo what \
Mr Crossin told you to do,please!'
    while bingo==False:
        x=input()
        if x<num:
            print'%s'%aa+str(x)+' is small'
        if x>num:
            print'%s'%aa+str(x)+' is big'
        if x==num:
            print'%s'%aa+str(x)+' is bingo'
            bingo=True
回复

使用道具 举报

0

主题

0

好友

12

积分

新手上路

Rank: 1

23#
发表于 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

24#
发表于 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

25#
发表于 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

26#
发表于 2020-3-16 20:55:17 |只看该作者
手机公众号上是3.0版本的 这个是2.0版本
回复

使用道具 举报

0

主题

0

好友

40

积分

新手上路

Rank: 1

27#
发表于 2020-3-16 21:21:37 |只看该作者
zzxomg 发表于 2015-3-12 21:08

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

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

28#
发表于 2020-3-16 22:37:28 |只看该作者
哦哦UP 发表于 2020-3-16 21:21
你的这个序号怎么加上去的

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

使用道具 举报

0

主题

0

好友

25

积分

新手上路

Rank: 1

29#
发表于 2021-8-11 11:15:16 |只看该作者
zzxomg 发表于 2015-3-12 21:08

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

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

30#
发表于 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-5-3 05:52 , Processed in 0.027004 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部