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?

問題概要

2つの整数A、Bが与えられる。2つの合計が10未満ならA+Bを、10以上ならerrorと出力する。

解法と実装

if文で実装できます。

A, B = map(int, input().split()) # 入力を受け取る
if A + B < 10: # 10以下の時
  print(A + B) # 答えを出力
else:
  print("error") # errorと出力

三項演算子でもかけます。

A, B = map(int, input().split())
print(A + B) if A + B < 10 else print("error")
0
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
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?