Python_1

来源:互联网 发布:java时间格式化年月日 编辑:程序博客网 时间:2024/06/10 12:05

Python_1 code_cademy

1.  Indentation 指的是缩进,空格。 比如for循环下的缩进格数,一直到return结束。

     python 中缩进格数可以为2(code_cademy), 也可以为4。在pycharm中为4个,一个程序中使用的空格数量应该相同。

2. 在数学运算中,指数运算使用 **  , 指数运算是 **,不是 ^ 
    eg:
     # Set eggs equal to 100 using exponentiation on line 3!
     eggs = 10 ** 2
     # Write your code above!
     print eggs

3. 一行的注释使用 #. 
    多行的文本注释使用三个上引号:""" 就像这样子 """ 

4. Modulo:Modulo returns the remainder from a division. So, if you type 3 % 2, it will return 1, because 2 goes into 3 evenly once, with 1 left over.
    使用的符号为 % 

5. syntax 句法, python syntax:python 的句法

6. x = "False",    x 是string类型,不是boolean类型

7. python 中 15/100 得零,大概是因为两个数都是整数。想要得到小数形式,应该:15.0/100
原创粉丝点击