学习python

来源:互联网 发布:首都 知乎 编辑:程序博客网 时间:2024/05/19 15:20

最近python这么火,做图像接触了一点点,一直想去学一学。但是前一段时间学业繁重,没有闲工夫去学,这段时间终于闲下来了,平时上上课,课后看看各种各样的书,在不经意间找到一本python教程,我和python的故事就这样开始了。

安装很简单,程序界面也很简洁。




python有几点我比较感兴趣:可移植性好,有丰富的工具(各种科学计算,图形工具机器人(PyRo),神经网络),程序好写,GUI,免费

好了 直接开始第一个程序

>>> print()
SyntaxError: invalid character in identifier
>>> print()
>>> print(123)
123
>>> print('1')
1
>>> print('123')
123
>>> print("123")
123
>>>  print("abc")
 
SyntaxError: unexpected indent

>>> print("abc")
abc
>>> print('abc')
abc
>>>

嗯 看来不仅要注意中文字符 空格也会报错


>>> 12+23.6
35.6
>>> 12/34
0.35294117647058826
>>> 12//34
0
>>> 12/28
0.42857142857142855
>>> 12/20
0.6
>>> 12//20
0
>>> 12*34/56
7.285714285714286
>>> 12*sin(12)
Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    12*sin(12)
NameError: name 'sin' is not defined
>>> import math
>>> sin(12)
Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    sin(12)
NameError: name 'sin' is not defined
>>> math.sin(12)
-0.5365729180004349
>>>


做数学运算挺简单的