1
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?

【4】【python】基本の基本:inputを使おう【その1】

Posted at

下記のコード

a = input("aの値は何ですか?")
b = input("bの値は何ですか?")
print("a+bは", a + b, "です")

結果は下記
test12_12_1.jpg

1+2なのに3になってくれませんね。

なのでintによって変数の内容を「正数型」であると指定します。

a = int(input("aの値は何ですか?"))
b = int(input("bの値は何ですか?"))
print("a+bは", a + b, "です")

結果は下記
test12_13.jpg

ちゃんと3になってくれました。

1
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
1
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?