#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 语法的更多相关文章

  1. python之最强王者(2)——python基础语法

    背景介绍:由于本人一直做java开发,也是从txt开始写hello,world,使用javac命令编译,一直到使用myeclipse,其中的道理和辛酸都懂(请容许我擦干眼角的泪水),所以对于pytho ...

  2. Python基本语法[二],python入门到精通[四]

    在上一篇博客Python基本语法,python入门到精通[二]已经为大家简单介绍了一下python的基本语法,上一篇博客的基本语法只是一个预览版的,目的是让大家对python的基本语法有个大概的了解. ...

  3. Python基本语法,python入门到精通[二]

    在上一篇博客Windows搭建python开发环境,python入门到精通[一]我们已经在自己的windows电脑上搭建好了python的开发环境,这篇博客呢我就开始学习一下Python的基本语法.现 ...

  4. python 缩进语法,优缺点

    Python的语法比较简单——采用缩进方式 缩进有利有弊: 好处之一是强迫你写出格式化的代码,但没有规定缩进是几个空格还是Tab.按照约定俗成的管理,应该始终坚持使用4个空格的缩进. 其二是强迫你写出 ...

  5. Python特殊语法:filter、map、reduce、lambda [转]

    Python特殊语法:filter.map.reduce.lambda [转] python内置了一些非常有趣但非常有用的函数,充分体现了Python的语言魅力! filter(function, s ...

  6. Python 基础语法(三)

    Python 基础语法(三) --------------------------------------------接 Python 基础语法(二)------------------------- ...

  7. Python基本语法初试

    编程环境: win7旗舰版 Python 3.2.2(default, Sep  4 2011,09:51:08) 代码来源:(Python菜鸟) 代码内容: Python基本的输出语句print(& ...

  8. Python 基础语法(四)

    Python 基础语法(四) --------------------------------------------接 Python 基础语法(三)------------------------- ...

  9. Python 基础语法(二)

    Python 基础语法(二) --------------------------------------------接 Python 基础语法(一) ------------------------ ...

  10. Python 基本语法1

    Python 基础语法(一) Python的特点 1. 简单 Python是一种代表简单思想的语言. 2. 易学 Python有极其简单的语法. 3. 免费.开源 Python是FLOSS(自由/开放 ...

随机推荐

  1. php查询文件扩展名

    //查询文件扩展名 function extension($str){ $str = implode("",explode("\\",$str)); $str ...

  2. 细说php一些常见的知识点

    一.认识脚本语言 1.常见的脚本语言有:html,css,js,asp,Python等 2.脚本语言的特性: a.语法和机构通常比较简单 b.学习和使用通常比较简单 c.通常以容易修改程序的“解释”作 ...

  3. null、undefined、false、0相等性比较

    之前在看<JavaScript权威指南>的时候看到三个相等性比较的式子: null == undefined ;// ==>true undefined == false;// == ...

  4. Linux Pthread 深入解析(转-度娘818)

    Linux Pthread 深入解析   Outline - 1.线程特点 - 2.pthread创建 - 3.pthread终止         - 4.mutex互斥量使用框架         - ...

  5. 【转载】ANSYS TRANSIENT ANSLYSIS [2]

    原文地址:http://sps.utm.my/wp-content/uploads/2014/12/ANSYS-day2-Transient-analysis.pdf

  6. Linear Algebra lecture9 note

    Linear independence Spanning a space Basis and dimension 以上概念都是针对a bunch of vectors, 不是矩阵里的概念   Supp ...

  7. Python 定位字符串

    一位朋友在玩闯关游戏时遇到如下问题: 感觉考查的就是字符串操作,用string模块就可完成:代码如下: # -*- coding: utf-8 -*- __author__ = 'Evilxr' im ...

  8. yii2史上最简单式安装教程,没有之一

    写一篇绝对堪称史上最easy的Yii2安装教程教你入门. 既然是安装Yii,我们先去官网下载一份Yii的高级模版,什么,你说打开页面乱七八糟的英文字母你看不懂?那这样大哥,你按照下面的截图进行操作好吧 ...

  9. Ubuntu16.04 安装配置Caffe

    Caffe已经是第三次安装配置了,为什么是第三次呢?因为我实在是低估了深度学习对于硬件的要求.第一次我在自己笔记本上配置的单核,CPU only ...  结果是,样例数据跑了4小时,这还怎么玩?第二 ...

  10. 性能测试知多少---系统架构分析 转自https://yq.aliyun.com/articles/35147?spm=5176.100239.blogcont24251.8.lS96At

    摘要: 有些事儿一旦放一放就难再拾起来,突然发现<性能测试知多少>这个系列两月没更新,关键时我都不知道啥时候放下的,总容易被各种技术所吸引走,如饥似渴的想学更多的东西,这几天一直有朋友问我 ...