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?

More than 1 year has passed since last update.

初心者によるatcoder(1回目):001 - Print 5+N

Last updated at Posted at 2022-10-28

10/28の演習記録です。
ご意見やいいねをいただけると喜びます。

【演習問題】
https://atcoder.jp/contests/math-and-algorithm/tasks/math_and_algorithm_a

【問題文】
image.png

【ソースコード】

apple = 5
 
mikan = input()
mikan_int = int(mikan)
#input()はstr型のためint型に変換した。
 
if 1 <= mikan_int <= 100:
  print(apple + mikan_int)
else:
  print("不正な値です")

【結果】

image.png

【感想】
input()がstr型で出力されと知らず、以下のエラーが出たため
int型に変換が必要である事が分かった。

TypeError: unsupported operand type(s) for +: 'int' and 'str'

参照ページ:https://note.nkmk.me/python-input-usage/

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?