Python-3 语法
#1 Tab键:
1)控制缩进
2)IDLE智能补全
#2 =等号:
1)=:表示赋值
2)==:表示判断
#3 流程图:
print('..........小甲鱼_1..........')
temp=input('猜测小甲鱼心里想的是哪个数字:')
guess=int(temp)
if guess==8:
print('中了')
print('哼,中了也没有奖励')
else:
print('猜错啦,小甲鱼想的是8!')
print('游戏结束,不玩了。')

改进:
1)条件 if-else
2)循环 while and
3)import random 模块:random.randint函数-返回一个随机的整型
import random
secret = random.randint(1,10)
print('..........小甲鱼_1..........')
_continue = input('''是否参与游戏?
是:Y\n''')
if _continue == 'Y':
temp = input('猜测小甲鱼心里想的是哪个数字:')
guess = int(temp)
while guess and _continue == 'Y':
if guess == secret:
print('中了')
print('哼,中了也没有奖励')
break
else:
if guess > secret:
print('大了大了!')
_continue = input('''是否继续猜测?
继续:Y\n''')
temp = input('继续猜测小甲鱼心里想的是哪个数字:')
guess = int(temp)
else:
print('小了小了!')
_continue = input('''是否继续猜测?
继续:Y\n''')
temp = input('继续猜测小甲鱼心里想的是哪个数字:')
guess = int(temp)
else:
print('游戏结束,不玩了。')
#4 内置函数 print、input
>>> dir(__builtins__)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
注:只有小写的部分是内置函数
>>> help(input)
Help on built-in function input in module builtins:
input(...)
input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading.
Python-3 语法的更多相关文章
- python之最强王者(2)——python基础语法
背景介绍:由于本人一直做java开发,也是从txt开始写hello,world,使用javac命令编译,一直到使用myeclipse,其中的道理和辛酸都懂(请容许我擦干眼角的泪水),所以对于pytho ...
- Python基本语法[二],python入门到精通[四]
在上一篇博客Python基本语法,python入门到精通[二]已经为大家简单介绍了一下python的基本语法,上一篇博客的基本语法只是一个预览版的,目的是让大家对python的基本语法有个大概的了解. ...
- Python基本语法,python入门到精通[二]
在上一篇博客Windows搭建python开发环境,python入门到精通[一]我们已经在自己的windows电脑上搭建好了python的开发环境,这篇博客呢我就开始学习一下Python的基本语法.现 ...
- python 缩进语法,优缺点
Python的语法比较简单——采用缩进方式 缩进有利有弊: 好处之一是强迫你写出格式化的代码,但没有规定缩进是几个空格还是Tab.按照约定俗成的管理,应该始终坚持使用4个空格的缩进. 其二是强迫你写出 ...
- Python特殊语法:filter、map、reduce、lambda [转]
Python特殊语法:filter.map.reduce.lambda [转] python内置了一些非常有趣但非常有用的函数,充分体现了Python的语言魅力! filter(function, s ...
- Python 基础语法(三)
Python 基础语法(三) --------------------------------------------接 Python 基础语法(二)------------------------- ...
- Python基本语法初试
编程环境: win7旗舰版 Python 3.2.2(default, Sep 4 2011,09:51:08) 代码来源:(Python菜鸟) 代码内容: Python基本的输出语句print(& ...
- Python 基础语法(四)
Python 基础语法(四) --------------------------------------------接 Python 基础语法(三)------------------------- ...
- Python 基础语法(二)
Python 基础语法(二) --------------------------------------------接 Python 基础语法(一) ------------------------ ...
- Python 基本语法1
Python 基础语法(一) Python的特点 1. 简单 Python是一种代表简单思想的语言. 2. 易学 Python有极其简单的语法. 3. 免费.开源 Python是FLOSS(自由/开放 ...
随机推荐
- HackerRank-Longest Subarray
give an array and target value, find the max length of the subarray which sum of the elements is les ...
- css z-index属性使用过程中遇到的问题
z-index属性在web开发中会经常使用,其主要的作用简单的说就是把元素的position设置为absolute.fixed之后,可以调节元素在文档上的层级关系.比如经常见到的dialog,mask ...
- Exchange的AutoDiscover服务
最近工作中涉及到Exchange的AutoDiscover服务,最初想学习后输出一个博客文章.但是最后是找到一篇中文博客文章已经非常清楚的解释了这个问题,如下: http://didda.blog.5 ...
- fastdfs 安装配置
介绍文档 1.安装 # wget # tar xf download # cd FastDFS/ # ./make.sh 运行文件 有报错信息 compilation terminated. ...
- python logging bydate
#!/usr/bin/env python #_*_coding:utf-8_*_ # vim : set expandtab ts=4 sw=4 sts=4 tw=100 : import logg ...
- iScroll知识点
1.如果你有一个复杂的DOM结构,最好在onload事件之后适当的延迟,再去初始化iScroll.最好给浏览器100或者200毫秒的间隙再去初始化iScroll. 2.iScroll作用于滚动区域的外 ...
- FCN网络的训练——以SIFT-Flow 数据集为例
参考文章: http://blog.csdn.net/u013059662/article/details/52770198 caffe的安装配置,以及fcn的使用在我前边的文章当中都已经提及到了,这 ...
- Android数据库的运用
很简单的应用,所以我直接简单明了. android中数据库的运用: 1.定义类继承SQLiteOpenHelper ps: public class DBHelper exten ...
- 查看Visual Studio异常内容
If Entity Framework throws a validation exception when saving, Visual Studio reports the message, Va ...
- HTML 代码复用实践 (静态页面公共部分提取复用)
原文:HTML 代码复用实践 上面的链接里面安装配置步骤已经非常详细,这里主要记录我操作过程中遇到的几个问题 gulp-file-include 的使用 按上面的步骤安装之后,node_mod ...