Advertisement
SimeonTs

SUPyF Objects and Classes - 04. Exercises

Aug 12th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.45 KB | None | 0 0
  1. """
  2. Objects and Classes
  3. Check your solution: https://judge.softuni.bg/Contests/Practice/Index/950#3
  4.  
  5. SUPyF Objects and Classes - 04. Exercises
  6.  
  7. Problem:
  8. Exercises are fun … Especially when they represent a problem from your exercises.
  9. Implement a class Exercise, which has a topic (string), a course_name (string), a judge_contest_link (string),
  10. and problems (collection of strings).
  11. You will receive several input lines containing information about a single exercise in the following format:
  12. {topic} -> {course_name} -> {judge_contest_link} -> {problem1}, {problem2}. . .
  13. You need to store every exercise in a Collection of Exercises. When you receive the command “go go go”, you end the input sequence.
  14. You must print every exercise, in the following format:
  15. “Exercises: {topic}
  16. Problems for exercises and homework for the "{course_name}" course @ SoftUni.
  17. Check your solutions here: {judge_contest_link}
  18. 1. {problem1}
  19. 2. {problem2}
  20. . . .”
  21.  
  22. Examples:
  23. Input:
  24. ObjectsAndSimpleClasses -> ProgrammingFundamentalsExtended -> https://judge.softuni.bg/Contests/439 -> Exercises, OptimizedBankingSystem, Animals, Websites, Boxes, BoxIntersection, Messages
  25. go go go
  26.  
  27. Output:
  28. Exercises: ObjectsAndSimpleClasses
  29. Problems for exercises and homework for the "ProgrammingFundamentalsExtended" course @ SoftUni.
  30. Check your solutions here: https://judge.softuni.bg/Contests/439
  31. 1. Exercises
  32. 2. OptimizedBankingSystem
  33. 3. Animals
  34. 4. Websites
  35. 5. Boxes
  36. 6. BoxIntersection
  37. 7. Messages
  38. """
  39.  
  40.  
  41. class Exercise:
  42.     def __init__(self, topic, course_name, judge_contest_link, problems):
  43.         self.topic = topic
  44.         self.course_name = course_name
  45.         self.judge_contest_link = judge_contest_link
  46.         self.problems = problems
  47.  
  48.  
  49. all_exercises = []
  50. while True:
  51.     inp = input()
  52.     if inp == "go go go":
  53.         break
  54.     data = [item for item in inp.split(" -> ")]
  55.     topic_ = data[0]
  56.     course_name_ = data[1]
  57.     j_c_l = data[2]
  58.     problems_ = [item for item in data[3].split(", ")]
  59.     a = Exercise(topic_, course_name_, j_c_l, problems_)
  60.     all_exercises += [a]
  61.  
  62.  
  63. for exercise in all_exercises:
  64.     print(f"Exercises: {exercise.topic}")
  65.     print(f"Problems for exercises and homework for the \"{exercise.course_name}\" course @ SoftUni.")
  66.     print(f"Check your solutions here: {exercise.judge_contest_link}")
  67.     counter = 1
  68.     for problem in exercise.problems:
  69.         print(f"{counter}. {problem}")
  70.         counter += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement