Advertisement
horozov86

Programmer

Jun 23rd, 2023
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. class Programmer:
  2.     def __init__(self, name, language, skills):
  3.         self.name = name
  4.         self.language = language
  5.         self.skills = skills
  6.        
  7.     def watch_course(self, course_name, language, skills_earned):
  8.         if language != self.language:
  9.             return f"{self.name} does not know {language}"
  10.         self.skills += skills_earned
  11.         return f"{self.name} watched {course_name}"
  12.        
  13.        
  14.     def change_language(self, new_language, skills_needed):
  15.         if self.skills >= skills_needed and new_language == self.language:
  16.        
  17.             return f"{self.name} already knows {new_language}"
  18.         return f"{self.name} needs {skills_needed - self.skills} more skills"
  19.        
  20.         if self.skills >= skills_needed and new_language != self.language:
  21.             previous_language = self.language
  22.             new_language = self.language
  23.             return f"{self.name} switched from {previous_language} to {new_language}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement