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?

問題概要

英大文字か英小文字が1文字与えられる。大文字ならA、小文字ならaを出力する。

解法と実装

isupper()で文字列が大文字かどうか判定できます。

S = input()
if S.isupper():
  print("A")
else:
  print("a")

upper()で文字列を大文字にすることができます。
大文字にしても、元の文字か変わらないかどうかで判定ができます。

S = input()
if S == S.upper(): # SとSを大文字にした時が等しいかどうか
  print("A")
else:
  print("a")

文字コードで比較することもできます。

S = input()
if ord(S) < ord("a"): # 文字コードの比較
  print("A")
else:
  print("a")
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?