Skip to content

Instantly share code, notes, and snippets.

@Ojha-Shashikant
Last active August 17, 2018 20:11
Show Gist options
  • Save Ojha-Shashikant/43a2ec31525da29b41a87862777eb27e to your computer and use it in GitHub Desktop.
Save Ojha-Shashikant/43a2ec31525da29b41a87862777eb27e to your computer and use it in GitHub Desktop.
percentage and rank of student based on marks scored in various subjects
''' percentage and rank of student based on marks scored in various subjects '''
# function to input marks in english
def input_english_marks():
english_marks = float(input("provide the marks scored english:" ))
if english_marks > 80:
print("Maximum marks in english is 80, please enter proper value")
english_marks = float(input("provide the marks scored in english:" ))
return english_marks
else:
return english_marks
# function to input marks in science
def input_science_marks():
science_marks = float(input("provide the marks scored science:" ))
if science_marks > 90:
print("Maximum marks in science is 90, please enter proper value")
science_marks = float(input("provide the marks scored in science:" ))
return science_marks
else:
return science_marks
# function to input marks in mathematics
def input_mathematics_marks():
mathematics_marks = float(input("provide the marks scored Mathematics:" ))
if mathematics_marks > 100:
print("Maximum marks in mathematics is 100, please enter proper value")
mathematics_marks = float(input("provide the marks scored mathematics:" ))
return mathematics_marks
else:
return mathematics_marks
# function to calculate percentage of student
def percentage_of_student():
english = input_english_marks()
science = input_science_marks()
mathematics = input_mathematics_marks()
percentage = ((english + science + mathematics)*100)/(80 + 90 + 100)
return percentage
# function to provide rank to student
def rank_of_student():
percent = percentage_of_student()
if percent >= 90:
print("You score first class marks")
elif 90 > percent >= 75:
print("You score second class marks")
elif 75 > percent > 35:
print("You score average marks")
elif percent <= 35:
print("You failed in exam")
# main function
def main():
rank_of_student()
# main starts here
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment