第二章 用Python设计第一个游戏[DDT书本学习 小甲鱼]

2.1 主线:变量-分支-循环-条件-函数【BIF内置函数】 等常规
文字游戏 猜数字
代码 '''----第一个小游戏---'''
temp=input("猜猜我地心里想的那一个数字?:")
guess=int(temp)
if guess==5:
print("你是我肚子里地小蛔虫么?")
print("=======================")
else:
print("你猜错了,我的心里想的是数字5")
print("游戏结束,不玩了")
运行结果
猜猜我地心里想的那一个数字?:7
你猜错了,我的心里想的是数字5
游戏结束,不玩了
2.2 Python没有大括号 采用缩进 非常精简 有层次
2.3 BIF 内置函数
可以用help()这个BIF用于查询功能描述
代码 help(print)
结果
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end=' ', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.

Daodantou:“不积跬步,无以至千里.”
原文地址:https://www.cnblogs.com/daodantou/p/10197750.html