In this lab, you use the pseudocode in figure below to add code to a partially c
ID: 3874053 • Letter: I
Question
In this lab, you use the pseudocode in figure below to add code to a partially created Python program. When completed, college admissions officers should be able to use the Python program to determine whether to accept or reject a student, based on his or her class rank.
Instructions
Study the pseudocode in picture above.
Write the interactive inputstatements to retrieve:
A student’s test score (testScoreString)
A student's class rank (classRankString)
Write the statements to convert the string representation of a student’s test score and class rank to the integer data type (testScoreand classRank, respectively).
The rest of the program is written for you.
Execute the program by clicking the "Run Code" button at the bottom and entering 87for the test score and 60 for the class rank.
Run the program again by entering 60 for the test score and 87 for the class rank.
Explanation / Answer
Python code:
#reading data from console into testScoreString and classRankString variables
testScoreString = raw_input("Please enter A student's test score ")
classRankString = raw_input("Please enter A student's class rank ")
#converting to integers
testScore = int(testScoreString)
classRank = int(classRankString)
#simplified the pseudocode logic by using "and" operator
if testScore>=90 and classRank>=25:
print "Accept"
elif testScore>=80 and classRank>=50:
print "Accept"
elif testScore>=70 and classRank>=75:
print "Accept"
else:
print "Reject"
Output: 1
Output: 2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.