LoginSignup
2
0

More than 5 years have passed since last update.

Processing使いがPythonに移行するときにハマった点

Last updated at Posted at 2015-06-20

わりと自分用メモなので鵜呑みにしないこと

1.for文がPythonは独特


for i in range(0,10):
    print i

どうやらPython3系とPython2系では少し違うらしい
2015/06/20午後9時53分更新

Python2系
range(mini,max)でminiからmaxまでのリストを作る
リストは配列みたいなもん。リストに入ってる数字の分だけfor文が実行される。range(max,min,-1)で10から1までのリストを作れる。

Python3系
Python3系ならlist(range(0,10))の方がいいかも。for文では動くのだけどlistを作るという説明はそぐわないかも?


for(int i = 0;i < 10;i++){
    println(i);
}

2.変数の作り方

num1 = 10
num2 = [10,20,30]
#↓これでもいけるPython2系
num2 = range(10,30,10)
#↓Python3系なら
num2 = list(range(10,30,10))

int num1 = 10;
int[] num2 = {10,20,30}

とりあえず、ここまでまた更新するかも

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0