Latest web development tutorials

Pythonは演習15を含み、

Pythonの100リー Pythonの100リー

タイトル:この質問を完了するために、ネストされた条件演算子を使用した:学術> = 90点、Aで表される学生は、Bで表される60から89点の間に、60点以下はCで表されます

プログラム解析:プログラムの解析:(> b)のA: ?Bこれは、条件演算子の基本的な例です。

ソースコード:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

score = int(raw_input('input score:\n'))
if score >= 90:
    grade = 'A'
elif score >= 60:
    grade = 'B'
else:
    grade = 'C'

print '%d belongs to %s' % (score,grade)

上の例の出力は、次のとおりです。

input score:
100
100 belongs to A

Pythonの100リー Pythonの100リー