zoukankan      html  css  js  c++  java
  • 《Python for Beginners》学习笔记(1)

    《Python for Beginners》为LearnStreet上的Python入门课程。课程网页设计得很友好,可以边学边练。作为Python的初学者,如果有C语言基础,理解起来也比较容易。该笔记将重点记录Python与C语言不同的语法和编程方法。

    Lesson 2 Variables, Numbers and Booleans 

    学习笔记:

    1.关键字(保留字):and, as, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while, with, yield.

    2.两种主要数据类型:整型(int)和浮点型(float)

    数据类型转换:
    int(x): 将浮点型转换为整型
    float(x): 将整型转换为浮点型

    查看变量的数据类型:type(x)

    3.布尔值:True or False

    4. 比较运算符
    == equal to
    <   strictly less than
    >   strictly greater than
    <= less than or equal to
    >= greater than or equal to
    !    negates any of the above (e.g., != is not equal) (不是很清楚怎么用)

    5. 算术运算符
    + add
    - subtract
    * multiply
    / divide
    ** power (5**2 = 25, or 5 to the second power) (与C语言不同)
    // floor division (与C语言不同)
    % modulus

  • 相关阅读:
    帮助理解Docker,生动装逼介绍Docker
    Java 最常见 200+ 面试题 + 全解析
    CentOS7.0 yum安装 docker
    集合总结
    C#复习笔记
    match方法的使用
    偏函数
    通用装饰器
    装饰器修饰带参数的功能函数
    多个装饰器的使用
  • 原文地址:https://www.cnblogs.com/geekham/p/2936947.html
Copyright © 2011-2022 走看看