#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. (转)Spring AOP实现方式(转)

    我们可以通过三种方式来使用Spring AOP,它们分别是:@Aspect-based(Annotation),Schema-based(XML),以及底层的Spring AOP API 底层的Spr ...

  2. GitHub的用法:到GitHub上部署项目

    先提供两个较好的Git教程: 1. 如何在github部署项目: lhttp://jingyan.baidu.com/article/656db918fbf70ce381249c15.html 2. ...

  3. springMVC 返回json 忽略类中属性的注解

    该注解使用在 类名,接口头上 @JsonIgnoreProperties(value={"comid"}) //希望动态过滤掉的属性 该注解使用在get方法头上 @JsonIgno ...

  4. ns115 step by step

    一,安装环境: sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev lib ...

  5. java二分查找举例讨论

    最近做笔试题有这么一个关于二分查找的例子. 给一个有序数组,和一个查找目标,用二分查找找出目标所在index,如果不存在,则返回-1-(其应该出现的位置),比如在0,6,9,15,18中找15,返回3 ...

  6. JSPatch – 动态更新iOS APP

    原文:http://blog.cnbang.net/works/2767/ JSPatch是最近业余做的项目,只需在项目中引入极小的引擎,就可以使用JavaScript调用任何Objective-C的 ...

  7. linux KERNEL 问题

    http://stackoverflow.com/questions/9305992/linux-threads-and-process 深入 Linux 的进程优先级(vruntime) https ...

  8. openssl 升级

    openssl version -a rpm -q --changelog  openssl | grep CVE bash -version #!/bin/bash if [[ $EUID -ne ...

  9. linux for循环更改文件名字

    #!/bin/bash # for a in CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo Ce ...

  10. TextBlock

    一.TextBlock与Lable TextBlock是比Lable更底层的控件如果用TextBlock可以完成的需求就尽量不用Lable可以稍微提升一点性能. 参考文档 二.TextBlock内容过 ...