自分は今pythonの勉強をしています。
pythonのバージョンは3.4.0です。
開発環境はIDLEを使っています。
a = input('a:')
b = input('b:')
while True:
a = a + 1
if a == 10:
break
c =float( a / b )
print('a/b=',c)
というちょっとしたプログラムを書きました。(a=1,b=2の場合)shellで実行すると
Traceback (most recent call last):
File "/home/tkberry/test2.py", line 4, in <module>
a = a + 1
TypeError: Can't convert 'int' object to str implicitly
が表示されます。
しかし、ubuntのterminalで実行すると
a:1
b:2
('a/b=', 1.0)
('a/b=', 1.0)
('a/b=', 2.0)
('a/b=', 2.0)
('a/b=', 3.0)
('a/b=', 3.0)
('a/b=', 4.0)
('a/b=', 4.0)
と表示されます。この違いは何でしょうか?初心者なのでへたくそなんですが、どうか回答よろしくお願いします
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/08/02 13:17