每天10分钟,轻松学会python游戏编程day(2)—简单的猜字游戏

每天10分钟,轻松学会python游戏编程day(2)—简单的猜字游戏

首页休闲益智我猜字特牛更新时间:2024-04-27

这个猜字游戏非常简单,用random.randint() 产生一个1-20之间的随机数,用for in in range(6)来控制猜字的机会为6次,

这里需要注意的是input() 接受输入的是字符串,需要用int() 将其转换为整型, 具体可以看help(input)。

这样我们第一个猜字游戏就完成了,是不是很简单,试试循环部分用while你们看看需要怎么改???动手吧。。

input(prompt=None, /)

Read a string from standard input.The trailing newline is stripped. The prompt string, if given, is printed to standard output without atrailing newline before reading input. If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z Return), raise EOFError.On *nix systems, readline is used if available.

好不好都欢迎关注我,评论吐槽,一起进步。

,
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved