0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python学習をやり直したので2.7と3.Xの文法上の違いを銘記します。

◆print文の書き方
Python2.7と3.Xで、括弧の有無に違いがあります。
例:a = 5 を出力するとき

Python2.7ではprint a
Python3.Xではprint(a)

◆整数の割り算の演算子
Python2.7と3.Xでは、結果が整数となる割り算の演算子が異なります。
例:a = 6 を2で割る

Python2.7ではprint a / 2 # 3と出力されます。
Python3.Xではprint(a // 2) # 3と出力されます。

Python2.7では整数の割り算に/を、Python3.Xでは整数の割り算に//を使用します。
他にも違いはありますが、ひとまず上記の2点を抑えれば大丈夫です。

0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?