YouTip LogoYouTip

Python Exercise Example15

# Python2.x Python Exercise Instance 15 [![Image 3: Python 100 Examples](#) Python 100 Examples](#) **Question:** Use nested conditional operators to complete this problem: students with academic scores >= 90 are represented by A, those between 60-89 are represented by B, and those below 60 are represented by C. **Program Analysis:** Program Analysis: (a>b) ? a:b is a basic example of a conditional operator. Program source code: ## Instance (Python 2.x) ```python #!/usr/bin/python # -*- coding: UTF-8 -*- score = int(raw_input('Enter score:n')) if score>= 90: grade = 'A' elif score>= 60: grade = 'B' else: grade = 'C' print '%d Belongs to %s' % (score,grade) ## Instance (Python 3.x) ```python
← Python Exercise Example16Python Exercise Example14 β†’