Python includes exercises 15
Title: Using nested conditional operator to complete this question: academic> = 90 points the students represented by A, between 60-89 points represented by B, 60 points or less is represented by C.
Program Analysis: The Program Analysis: (a> b) a: ? B This is a basic example of a conditional operator.
Source Code:
#!/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)
The above example output is:
input score: 100 100 belongs to A