Ceecode
Ceecode

Reputation: 1

Python Assistance with Functions

I would like to create a program named admission that takes as Input the student name, GPA and the admission Test Score, the application should display if the student got accepted or rejected. The program should use a function named AcceptOrReject( gpa, testScore) to control the program. Acceptance is based on the following criteria:

The student can get accepted in the following two cases:

1- if the GPA is less than 3.0, the test score has to be more than 80 to get accepted

2-if the GPA is more or equal to 3.0 then the test score has to be more than 60 to get accepted Otherwise, the student will get Rejected.**

So I understand the objective at hand, but I'm having trouble trying to translate it to my actual code. I feel like it's a really simple assignment, but I'm not sure.

I know that we're going to need an if statement for the GPA, but how would you go about doing the test scores to determined if they failed or not? So far I have this segment and I'm not sure how to continue

    def AcceptOrReject(gpa, testscore):
    if gpa < 3.0:
        return testscore
     #I don't think I need a return testscore there.

    name=(input("Please provide your full name: "))
    testscore=float(input("What is your admissions test score? "))
    gpa=float(input("What is your GPA? "))

I'm figuring stuff out as I go, but any type of direction will be gladly appreciated. Please let me know if there's any more information that I can provide. Hopefully, I've provided as much information to you all.

Upvotes: 0

Views: 424

Answers (4)

Ceecode
Ceecode

Reputation: 1

Thank you for the assistance. Everyone's aid greatly helped with my understanding of my program. This community works like magic and most of the people I've seen are really helpful too. Thank you once again! @ghareebfathy @TheDeadGuy @Ruan

Upvotes: 0

ghareeb fathy
ghareeb fathy

Reputation: 455

def AcceptOrReject(student_name,gpa,testscore):
        if (gpa < 3.0 and testscore > 80):
            return True
        elif gpa >= 3.0 and testscore > 60:
            return True
        else:
            return False
if __name__ == '__main__':
        student_name=(input("Please provide your full name: "))
        testscore=float(input("What is your admissions test score? "))
        gpa=float(input("What is your GPA? "))
        print(AcceptOrReject(student_name,gpa,testscore))

Upvotes: 0

rrswa
rrswa

Reputation: 1050

It makes the most sense for the AcceptOrReject to return a boolean value based on the given GPA and Test score.

Since the problem states:

...the application should display if the student got accepted or rejected.

we can print "Accepted" or "Rejected" based on the return value of the function.

The solution is for AcceptOrReject to check both criteria in an if statement, and return true if that criteria is met. Otherwise, we reject at the end since both criteria weren't met.
Finally, we can print "Accepted" or "Rejected" based on the return value of AcceptOrReject.

def AcceptOrReject(gpa, testscore):
    # If GPA is less than 3.0 and testscore is more than 80 then
    if (gpa < 3.0 and testscore > 80):
        # Accept
        return True
    # Otherwise, if gpa is more or equal to 3.0 and testscore is more than 60 then
    elif (gpa >= 3.0 and testscore > 60):
        # Accept
        return True
    # Otherwise
    else:
        # Reject
        return False


testscore = float(input("What is your admissions test score? "))
gpa = float(input("What is your GPA? "))

if AcceptOrReject(gpa, testscore):
    print("Accepted")
else
    print("Rejected")

Upvotes: 2

Dead Guy
Dead Guy

Reputation: 57

I thnk that would help:

def AcceptOrReject(gpa,testscore):
    if gpa<3 and testscore>80:
        print("Accepted!")

    elif gpa>3 and testscore>60:
        print("Accepted!")

    else:
        print("Rejected")


student_name=input("What is your Name? ")
student_gpa=int(input("What is your GPA? "))
testscore=int(input("What is your testscore? "))


print(AcceptOrReject(student_gpa,testscore)')

.

I did not understand the use of name that you take as input. Place it accordingly where it is needed!

Upvotes: 0

Related Questions