# File: moveOn3.py # Author: Dr. Gibson # Date: 9/19/2017 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that asks the user for # their major and grade, and prints out whether they are # eligible to move on to CMSC 202 in the next semester. # This version uses logical operators rather than # nested decision structures. def main(): # get major and grade from the user major = input("Please enter your major: ") grade = input("Please enter your grade: ") # for everyone, an A or B counts as passing the class if grade == "A" or grade == "B": print("You can take CMSC 202!") # use PARENTHESES to ensure that the parts of the # conditional are evaluated in the correct order elif grade == "C" and (major == "CMSC" or major == "CMPE"): # for CMSC and CMPE majors, a C is not enough to pass print("You cannot move on to CMSC 202.") # note that the OR for majors used above switched to an AND instead # they cannot be a CMSC major *AND* they cannot be a CMPE major elif grade == "C" and major != "CMSC" and major != "CMPE": # for all other majors, a C is enough print("You can take CMSC 202!") # any other grade does not count as passing, regardless of major else: print("You cannot move on to CMSC 202.") main()