fork download
  1. def determine_pass_fail(scores, passing_score=50):
  2. """
  3. Determines if a student passes or fails based on their scores in multiple subjects.
  4.  
  5. Args:
  6. scores: A dictionary where keys are subject names and values are scores.
  7. passing_score: The minimum score required to pass in each subject.
  8.  
  9. Returns:
  10. "Pass" if the student passes in all subjects, "Fail" otherwise.
  11. """
  12.  
  13. for subject, score in scores.items():
  14. if score < passing_score:
  15. return "Fail" # Fails if any subject is below passing score
  16. return "Pass" # Passes only if all subjects are above passing score
  17.  
  18.  
  19. # Example usage:
  20. student_scores = {
  21. "Math": 75,
  22. "Science": 60,
  23. "English": 80,
  24. "History": 45
  25. }
  26.  
  27. result = determine_pass_fail(student_scores)
  28. print(f"The student's result is: {result}")
Success #stdin #stdout 0.03s 9600KB
stdin
Standard input is empty
stdout
The student's result is: Fail