Xin Liu
* Use python 3.0 or later version * Major differences from earlier versions * Interactive mode * For quick experiments * “python3” to enter * print(’python programming is fun!’) * “Ctl+D” to quit * Script mode * For regular programs, that can be executed repeatedly * Edit a program (with gedit) * python3 myprogram.py
* In gedit, create the first.py containing the following program * In terminal, run the program by typing print(‘hello world!’) print(‘this is my first python program’) Print(‘it’s funny’) Python3 first.py
* (0, 0) (100, 100) Cartesian plane
* import turtle * clear() * title(‘window name’) * goto(x, y) * forward(distance) * back(distance) * left(angle) * right(angle) * circle(radius) * begin_fill() * end_fill() * pencolor(r, g, b), 0 <= r, g, b <= 1 * fillcolor(r, g, b) * write(‘a string’)
* Just to get a feeling of programming from turtle import * color('red', 'yellow') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done()