Python Speed Learning

Similar documents
Python Speed Learning

Visual Python, Numpy, Matplotlib

Visual Python, Numpy, Matplotlib

listings-ext

PowerPoint プレゼンテーション

PowerPoint Presentation

永和システムマネジメント SP 安井力 東京支社 Python 勉強会実習資料 2005/12/28 この資料の使い方最初から順に試してください 初心者は 書かれたとおり入力して ほかにも似た例を試してみてください 初級者は 書かれたとおり入力して なぜそれで動くのか調べてください 中級者は 設問か

RHEA key

num2.dvi

1 VisBAR edu H 2 O.....

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す PYTHON3 #coding: utf-8 import pygame from pygame.lo

2015 I ( TA)


haskell.gby

RL_tutorial

cards.gif from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_i

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

Boo Boo 2 Boo 2.NET Framework SDK 2 Subversion 2 2 Java 4 NAnt 5 Boo 5 5 Boo if 11 for 11 range 12 break continue 13 pass

from Tkinter import * root = Tk() c0 = Canvas(root, width = 400, height = 300) c0.pack() image_data = PhotoImage(file = c1.gif ) c0.create_image(200,

Windows (L): D:\jyugyou\ D:\jyugyou\ D:\jyugyou\ (N): en2 OK 2

listings-ext

Python C/C++ IPMU IRAF

nakao

all.dvi

コンピュータ概論

1 matplotlib matplotlib Python matplotlib numpy matplotlib Installing A 2 pyplot matplotlib 1 matplotlib.pyplot matplotlib.pyplot plt import import nu



/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental data structures /06/14(Tue) / Memory Management

from tkinter import * root = Tk() # variable teban = IntVar() teban.set(1) # def start(): canvas.create_rectangle(0, 0, 560, 560, fill= white ) for k

(Basic Theory of Information Processing) Fortran Fortan Fortan Fortan 1

Copyright c 2006 Zhenjiang Hu, All Right Reserved.

Windows [ ] [ (R)..] cmd [OK] Z:\> mkdir progi [Enter] \ ) mkdir progi ) (command ) help [Enter] help ( help ) mkdir make directory Windows ) mkdir mk

Java updated

( ) ( ) lex LL(1) LL(1)

Parametric Polymorphism

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

Java演習(4) -- 変数と型 --

スライド 1

Microsoft PowerPoint _watanabe.pptx

1 6/13 2 6/20 3 6/27 4 7/4 5 7/11 6 7/18 N 7 7/25 Warshall-Floyd, Bellman-Ford, Dijkstra TSP DP, 8/1 2 / 36

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

Python (Anaconda ) Anaconda 2 3 Python Python IDLE Python NumPy 6

教室案内.pptx

Python3 Next 2

スライド 1

Agenda Motivation How it works Performance Limitation Conclusion

() / (front end) (back end) (phase) (pass) 1 2

untitled

ohp08.dvi

Ruby Ruby ruby Ruby G: Ruby>ruby Ks sample1.rb G: Ruby> irb (interactive Ruby) G: Ruby>irb -Ks irb(main):001:0> print( ) 44=>

Windows Cygwin Mac *1 Emacs Ruby ( ) 1 Cygwin Bash Cygwin Windows Cygwin Cygwin Mac 1 Mac 1.2 *2 ls *3 *1 OS Linux *2 *3 Enter ( ) 2

:56 1 (Forward kinematics) (Global frame) G r = (X, Y, Z) (Local frame) L r = (x, y, z) 1 X Y, Z X Y, Z 1 ( ) ( ) 1.2 (Joint rotati

OpenCV IS Report No Report Medical Information System Labratry

2012 IA 8 I p.3, 2 p.19, 3 p.19, 4 p.22, 5 p.27, 6 p.27, 7 p

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

untitled

超初心者用

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

Python2 Python3 Python 2.7 Python 3.6 Python2 Python3 Python 2.7 Python3.6 Python Python Anaconda Python Anaconda Python

復習 プログラミング 1 ( 第 4 回 ) 関数の利用 2 ループ処理 (while 文 ) 1. Chapter の補足 2 1. 関数とローカル変数 2. Chapter 3.1 の補足 1. Iteration, looping ( 反復処理 ) 2. ループ処理の例 実行例 3

r08.dvi

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

たのしいプログラミング Pythonではじめよう!

Microsoft PowerPoint - CproNt02.ppt [互換モード]

Jacques Garrigue

I J

ML Edinburgh LCF ML Curry-Howard ML ( ) ( ) ( ) ( ) 1


Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 関数とメソッド 関数とメソッド Python には関数 (function) とメソッド (method) が有る モジュール内に def で定義されて居る物が関数 クラス内に def で定義されて居る物がメソッドに成る ( 正確にはクラスが

スライド 1

,,,,., C Java,,.,,.,., ,,.,, i

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

1.ppt

K227 Java 2

EnSight 10.1の新機能

導入基礎演習.ppt

piyo0704a.rtfd

プログラミング 1 ( 第 5 回 ) ループ処理 (for 文 ) range() 関数とリストによるシーケンス集合表現 1. Chapter 3.2 For Loops 1. もう一つのループ処理 2. シーケンス集合とコード例 2. Chapter 3.4 A Few Words About

離散数理工学 第 2回 数え上げの基礎:漸化式の立て方

ex01.dvi

1st-session key

コメント プログラム中には コメントを加える事ができます 処理の際には無視されるので 注釈や覚え書きとして利 できます print("hello Sapporo!") # Hello Sapporo! と 表 する # コメントは無視される 字列 字列とは 単語や 章のような 字の連なったものです

r1.dvi

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

‘îŁñ›È−wfiÁŁÊ”À„±I --Tensorflow‡ð”g‡Á‡½fl»ŁÊ›ð’Í--

fp.gby

Informatics 2010.key

Python ( ) Anaconda 2 3 Python Python IDLE Python NumPy 6 5 matpl

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

B演習(言語処理系演習)第一回

No10_1[1].pdf

N88 BASIC 0.3 C: My Documents 0.6: 0.3: (R) (G) : enterreturn : (F) BA- SIC.bas 0.8: (V) 0.9: 0.5:


Microsoft PowerPoint - dm1_7.pptx

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

Ver.1 1/17/2003 2

Transcription:

Python Speed Learning 1 / 76

Python 2 1 $ python 1 >>> 1 + 2 2 3 2 / 76

print : 1 print : ( ) 3 / 76

print : 1 print 1 2 print hello 3 print 1+2 4 print 7/3 5 print abs(-5*4) 4 / 76

print : 1 print 1 2 print hello 3 print 1+2 4 print 7/3 5 print abs(-5*4) : 1 1 2 hello 3 3 4 2 5 20 4 / 76

,, (/) 7 / 3 2 7 / 3.0 2.3333333333333335 7 / float(3) 2.3333333333333335 5 / 76

: 1 = : ( ; variable), 6 / 76

:?, python? 1 a = 1 + 2 2 print a 3 b = a + 3 4 print b 5 a = a + 4 6 print a 7 / 76

:?, python? 1 a = 1 + 2 2 print a 3 b = a + 3 4 print b 5 a = a + 4 6 print a : 1 3 2 6 3 10 7 / 76

... : 1 a = 1 + 2 2 print a 3 print b 8 / 76

... : 1 a = 1 + 2 2 print a 3 print b : 1 3 2 Traceback (most recent call last): 3 File "a.py", line 3, in <module> 4 print b 5 NameError: name b is not defined 8 / 76

:.,, ( ),., 1. : x, y, tanaka, Kouji Uehara, World Cup 2013 : J-League, hungry?, 4WD 9 / 76

: 1 def (,,...): 2 3 4... : 10 / 76

: 1 # 2 def f(x, y): 3 a = x + y 4 return a * a 5 6 # ( ) 7 print f(10, 20) + 30 11 / 76

: 1 # 2 def f(x, y): 3 a = x + y 4 return a * a 5 6 # ( ) 7 print f(10, 20) + 30 : 1 930 11 / 76

python, 1 def f(x, y): 2 a = x + y 3 return a * a 4 print f(10, 20) + 30 1 f ( ) 2 print. 1,f(10, 20) + 30. 2, f(10, 20) x=10, y=20 f 3 return : 1 return,, 12 / 76

:?, python? 1 def f(x, y): 2 print 1 3 print hello 13 / 76

:?, python? 1 def f(x, y): 2 print 1 3 print hello! 13 / 76

:? 1 def f(x, y): 2 print x 3 print y 4 return x + y 5 6 print f(10, 20) 14 / 76

:? 1 def f(x, y): 2 print x 3 print y 4 return x + y 5 6 print f(10, 20) 1 10 2 20 3 30 14 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) 15 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) : 1 10 2 20 3 None 15 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) : 1 10 2 20 3 None (return ). return,,, None 15 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) + 30 16 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) + 30 : 1 10 2 20 3 Traceback (most recent call last): 4 File "a.py", line 6, in <module> 5 TypeError: unsupported operand type(s) for +: NoneType and int 16 / 76

:? : 1 def f(x, y): 2 print x 3 print y 4 x + y 5 6 print f(10, 20) + 30 None, 30, : 1 10 2 20 3 Traceback (most recent call last): 4 File "a.py", line 6, in <module> 5 TypeError: unsupported operand type(s) for +: NoneType and int 16 / 76

1 def f(x, y): 2 print hello 3 print bye 4 print 10 5 f(30, 40) 17 / 76

1 def f(x, y): 2 print hello 3 print bye 4 print 10 5 f(30, 40) 1 10 2 hello 3 bye print hello, print bye f ( ) print 10 f f(30,40), print hello, print bye 17 / 76

Python 1 def f(x): 2 print x 3 print x+1 1 File "a.py", line 3 2 print x+1 3 ^ 4 IndentationError: unexpected indent 18 / 76

Python 1 print 10 2 def f(x): 3 print x 4 5 print 20 1 File "a.py", line 5 2 print 20 3 ^ 4 IndentationError: unindent does not match any outer indentation level 19 / 76

Emacs Emacs Python (xxx.py), Tab ( C-i), Tab, 20 / 76

1 def f(x): 2 print x 3 y = x + 1 4 return y * y 5 def g(x): 6 y = f(x + 1) 7 print x 8 return x + y 9 print g(10) 21 / 76

1 def f(x): 2 print x 3 y = x + 1 4 return y * y 5 def g(x): 6 y = f(x + 1) 7 print x 8 return x + y 9 print g(10) 1 11 2 10 3 154 21 / 76

,. : 1 def f(x, y): 2 return x - y 3 4 print f(2, 3) # x=2, y=3, x, y 1 print f(y=10, x=20), 22 / 76

,, ( ) 1 def g(x, y=1): 2 return x - y 3 4 print g(2) # x=2, y=1 5 print g(x=2) # x=2, y=1 6 print g(2, 3) # x=2, y=3 7 print g(x=2, y=3) # x=2, y=3 8 print g(y=3) # NG x Visual Python, numpy, 23 / 76

: 1 def f(x): 2 print x 3 y = x + 1 4 return y * y 5 def g(x): 6 y = f(x + 1) 7 print x 8 return x + y 9 print g(10), f x (y) g x (y),?. ( ) ( ) 24 / 76

1 def f(x): 2 y = x + 1 3 f(10) 4 print y : 1 Traceback (most recent call last): 2 File "a.py", line 5, in <module> 3 print y 4 NameError: name y is not defined 25 / 76

( ), 1 z = 10 2 def f(x): 3 return x + z 4 print f(20) 5 z = 30 6 print f(20) 26 / 76

( ), 1 z = 10 2 def f(x): 3 return x + z 4 print f(20) 5 z = 30 6 print f(20) : 1 30 2 50, ( ) 26 / 76

import : 1 from import * : 27 / 76

import : 1 print cos(0.1) : 1 Traceback (most recent call last): 2 File "a.py", line 1, in <module> 3 print cos(0.1) 4 NameError: name cos is not defined : 1 from math import * # math import 2 print cos(0.1) : 1 0.995004165278 28 / 76

import : 1 from visual import * 2 sphere() : 29 / 76

import : 1 import : from import *,,. 1 import visual 2 visual.sphere(), OK, 30 / 76

Python Python Visual Python, Matplotlib, numpy? ( )? python, dir( ) 1 from visual import * 2 print dir(visual) 1 [ ALLOW_THREADS, BUFSIZE,... 2... sphere,... ] 31 / 76

print (print ) ( = ) (def...) return (return ) import (from import *) 32 / 76

, ( ) 33 / 76

for (1) ( ): 1 for in range(, ): 2 3 4... : 1 for i in range(a, b): 2... 3..., i = a, a + 1,..., b 1,... : range( ) range(0, ) 34 / 76

for (1) : 1 1 for x in range(3, 7): 2 print x * x 35 / 76

for (1) : 1 1 for x in range(3, 7): 2 print x * x 1 9 2 16 3 25 4 36 35 / 76

for (1) : 2 1 def hatena(n): 2 a = 1 3 for i in range(0, n): 4 a = 2 * a + 1 5 return a 6 print hatena(5) 36 / 76

for (1) : 2 1 def hatena(n): 2 a = 1 3 for i in range(0, n): 4 a = 2 * a + 1 5 return a 6 print hatena(5) 1 63 36 / 76

for (1) : 3 1 def hatena(n): 2 s = 0 3 for i in range(0, n): 4 s = s + i * i 5 return s 6 print hatena(8) 0 2 + 1 2 + + (n 1) 2 s = s + i i... 37 / 76

for (1) : 3 1 def hatena(n): 2 s = 0 3 for i in range(0, n): 4 s = s + i * i 5 return s 6 print hatena(8) 1 140 0 2 + 1 2 + + (n 1) 2 s = s + i i... 37 / 76

if : 1 if 1: 2 3... 4 elif: 2: 5 6... 7... 8 else: 9 10... elif. elif, else: ( ) : 1 (0) ( 1...) 2 (0) 2 ( 2...) 38 / 76

if (1) 1 def one_two_many(x): 2 if x == 1: 3 return ikko 4 elif x == 2: 5 return niko 6 else: 7 return takusan 8 print one_two_many(2) 9 print one_two_many(3) 39 / 76

if (1) 1 def one_two_many(x): 2 if x == 1: 3 return ikko 4 elif x == 2: 5 return niko 6 else: 7 return takusan 8 print one_two_many(2) 9 print one_two_many(3) 1 niko 2 takusan 39 / 76

if (2) 1 def nabetsune(): 2 for i in range(1, 41): 3 if i % 3 == 0 or i % 10 == 3 or 30 < i < 40: 4 print i, "!!!!!" 5 else: 6 print i 7 8 nabetsune() 40 / 76

if (2) 1 def nabetsune(): 2 for i in range(1, 41): 3 if i % 3 == 0 or i % 10 == 3 or 30 < i < 40: 4 print i, "!!!!!" 5 else: 6 print i 7 8 nabetsune() 1 1 2 2 3 3!!! 4... 40 / 76

,, (e.g.,,,,,,... ),, ( ) 41 / 76

: 1 [,,..., ] : ( ) 42 / 76

: 1 from math import * 2 x = 20 3 a = [ 1, 1+2, cos(0.0), x ] 4 print a 5 print len(a) # 6 print a[2] # 7 b = a + [ 1.2, 3.4 ] # 2 8 print b 9 c = [ a, a, a ] # 10 print c[1][2] # c 1 ( ) 2 1 [1, 3, 1.0, 20] 2 4 3 1.0 4 [1, 3, 1.0, 20, 1.2, 3.4] 5 1.0 43 / 76

:,,,,,, 1 def f(l): 2 return l[0] 3 4 print f([1,2,3]) 44 / 76

,, 1 a = [ 2, 3, 5 ] 2 a.append(7) # 3 a[2] = 50 4 del a[1] # a[1]. 5 b = [ a, a, a ] 6 print b 7 a[2] = 30 # 8 print b 1 [[2, 50, 7], [2, 50, 7], [2, 50, 7]] 2 [[2, 30, 7], [2, 30, 7], [2, 30, 7]] 45 / 76

for : 1 [ for in range(, ) ], for ( ) : ( for in ) 46 / 76

: 1 >>> [ x * x for x in range(0, 5) ] 2 -> [0, 1, 4, 9, 16] 1 >>> sum([ x * x for x in range(0, 5) ]) 2 -> 30 1 s = [] 2 for x in range(0, 5): 3 s.append(x * x) 1 s = [] 2 for x in range(0, 5): 3 s += x * x ( : s += E s = s + E ) 47 / 76

: 1,,...,, 1 (,,..., ) :!, len(...) ( )...[...] ( )... +... ( ) 48 / 76

,,, 1 a = (1.1, 2.2, 3.3) 2 a.append(4.4) # NG 3 del a[1] # NG 4 a[1] = 22 # NG 5 a = (4.4, 5.5) # OK 6 a = a + (6.6, 7.7) # OK 2, 49 / 76

1 def polar(x, y): 2 r = sqrt(x * x + y * y) 3 theta = atan2(y, x) 4 return (r,theta) 1 r,theta = polor(3, 4)? OK 1 [a0,a1,a2] = range(3,6) # a0=3, a1=4, a2=5 50 / 76

: 1 "... " 2... 3 """... """ 4....? ",. a = he greeted, "hi" b = "Obama s lecture" 3 (""", ),, len(...)...[...]... +... 51 / 76

: ( ) x, 1 print x,, 1 print "x = %s" % x 1 from math import * 2 y = cos(3.14) 3 print "cos(3.14) = %s" % y 52 / 76

: 2 2, % 1 from math import * 2 x = 2.3 3 print "cos(%s) = %s" % (x, exp(x)) 53 / 76

:, 1 1 % 2, 1, 1 i %s, 2 i %s,, %s... %d : %9d :. 9 9 %f : %.3f :., 3 54 / 76

(1) Python,,, (visual vector, numpy ), Python 5 55 / 76

(2) Python,,, (, ),,, +, len, [...] numpy Visual Python vector, 56 / 76

for (2) : 1 for in : 2 3 4...,, range(a, b),,,,, range(a, b) [ a, a + 1,...b 1 ] 57 / 76

for (2) : 1 for x in [ 2, 3, 5 ]: 2 print x 3 for x in "hello": 4 print x 1 2 2 3 3 5 4 h 5 e 6 l 7 l 8 o 58 / 76

for (2) 1 A = [ (0,1), (2,3), (4, 5) ] 2 for x,y in A: 3 print x + y 1 1 2 5 3 9 59 / 76

for (2) : zip zip(x, Y ) for 1 X = [ 1, 2, 3 ] 2 Y = [ 1, 4, 9 ] 3 for x,y in zip(x, Y): 4 print x + y 1 2 2 6 3 12 60 / 76

for (2) : enumerate enumerate(l) ( ; 0, 1, 2,... ) 1 def find_space(): 2 for i,c in enumerate("hello world"): 3 if c == : 4 return i 5 return -1 1 5 61 / 76

while : (for ) break : for, while continue : for, while ( ), Python 4 62 / 76

: Python,, etc. 63 / 76

: 1 class : 2 3 4... : ( ), 64 / 76

: 1 class nothing: 2 pass # 3 4 # nothing 5 m = nothing() 6 # ( ) 7 m.x = 10 8 m.y = 20 9 # 10 print m.x + m.y 11 # 12 13 def take_nothing(n): 14 n.x = n.x + 100 15 16 take_nothing(m) 17 print m.x 65 / 76

: init, ( ) ( self ) 1 class baseball_team: 2 # 3 def init (self, name, manager, players): 4 self.name = name 5 self.manager = manager 6 self.players = players 7 # 8 def add_player(self, p): 9 self.players.append(p) 66 / 76

: 1 # -> init 2 r = baseball team("nipponham", "Kuriyama", 3 [ "Inaba", "Saito", "Takeda" ]) 4 print r.players 5 # 6 r.add player("ohtani") 7 print r.players 67 / 76

: 1 # -> init 2 r = baseball team("nipponham", "Kuriyama", 3 [ "Inaba", "Saito", "Takeda" ]) 4 print r.players 5 # 6 r.add player("ohtani") 7 print r.players 1 [ "Inaba", "Saito", "Takeda" ] 2 [ "Inaba", "Saito", "Takeda", "Ohtani" ] 67 / 76

,,, Visual Python, numpy,,, (, ) (vector, sphere, + ) 1 center = vector(2, 3, 4) 2 s = sphere(pos=center) 3 s.pos = center + vector(1, 1, 1) 68 / 76

add (self, o), (+) x + y, x. add (y) 1 class vector: 2 def init (self, x, y, z): 3 self.x = x 4 self.y = y 5 self.z = z 6 def add (self, o): 7 return vector(self.x + o.x, self.y + o.y, 8 self.z + o.z) 9 10 u = vector(1,2,3) 11 v = u + vector(4, 5, 6) # u. add (vector(4, 5, 6)) 12 print v, sub, mul, div 69 / 76

Python, +, -, *,, Python, ( ), Visual Python vector ( ), numpy array, mat,,, vector, + 70 / 76

Visual Python 1 from visual import * 2 s1 = sphere(color=color.red) # 3 s2 = sphere(pos=vector(1.0, 2.0, 3.0), radius=0.1) 4 # s1, s2 5 rate(0.3) # 3.3 (0.3 / ) 6 # 7 s2.color = color.green # 8 rate(0.3) # 3.3 (0.3 / ) 9 s2.pos = s2.pos + 0.5 * vector(-1.0,-1.0,-1.0) # Visual Python sphere, (color, radius, pos ),,, OK (, s1.vel = ) 71 / 76

Visual Python 1 from visual import * 2 s1 = sphere(color=color.red) # 3 s2 = sphere(pos=vector(1.0, 2.0, 3.0), radius=0.1) 4 # s1, s2 5 rate(0.3) # 3.3 (0.3 / ) 6 # 7 s2.color = color.green # 8 rate(0.3) # 3.3 (0.3 / ) 9 s2.pos = s2.pos + 0.5 * vector(-1.0,-1.0,-1.0) # Visual Python vector 3 +, * 72 / 76

Visual Python vector 1 >>> from visual import * 2 >>> v = vector(1,2,3) 3 >>> v 4 vector(1, 2, 3) 5 >>> v[0] 6 1.0 7 >>> v.x 8 1.0 9 >>> 2 * v 10 vector(2, 4, 6) 11 >>> v + v 12 vector(2, 4, 6) 13 >>> dir(v) 14 [..., astuple, clear, comp, cross, diff_angle, dot, mag, mag2, norm, proj, rotate, x, y, z ] 73 / 76

Visual Python vector 1 >>> v.mag 2 3.7416573867739413 3 >>> v.mag2 4 14.0 5 >>> v.dot(v) # 6 14.0 7 >>> v.norm() 8 vector(0.267261241912424, 0.534522483824849, 0.801783725737273) 9 >>> v.mag * v.norm() 10 vector(1, 2, 3) 11 >>> v.cross(vector(1,1,1)) # 12 vector(-1, 2, -1) 74 / 76

Visual Python 1 from visual import * 2 s1 = sphere(color=color.red) # 3 s2 = sphere(pos=vector(1.0, 2.0, 3.0), radius=0.1) 4 # s1, s2 5 rate(0.3) # 3.3 (0.3 / ) 6 # 7 s2.color = color.green # 8 rate(0.3) # 3.3 (0.3 / ) 9 s2.pos = s2.pos + 0.5 * vector(-1.0,-1.0,-1.0) # Visual Python rate(f),, f / ( 1/f ) rate, ( ) 75 / 76

( ), Python, # 1 def main(): 2 # location of the pointmass 3 p = vector(1,2,3) 4 # the pointmass 5 s = sphere(pos=p) 6 # the spring 7 sp = helix(pos=p) 8..., 1 1 #! -*- coding: utf-8 -*- 76 / 76