Примеры поздравлений по поводу завершения курса Udemy

Вот несколько способов создания поздравления с завершением курса Udemy, а также примеры кода:

Метод 1: использование простого оператора печати

print("Congratulations on completing the Udemy course!")

Метод 2. Использование форматированных строк

course_name = "Web Development"
print(f"Congratulations on completing the {course_name} course!")

Метод 3: использование конкатенации

course_name = "Data Science"
print("Congratulations on completing the " + course_name + " course!")

Метод 4. Использование функции

def congratulate(course):
    return "Congratulations on completing the " + course + " course!"
course_name = "Python Programming"
print(congratulate(course_name))

Метод 5. Использование строки шаблона

from string import Template
course_name = "Machine Learning"
template = Template("Congratulations on completing the $course course!")
message = template.substitute(course=course_name)
print(message)

Метод 6. Использование класса

class Congratulator:
    def __init__(self, course):
        self.course = course

    def congratulate(self):
        return f"Congratulations on completing the {self.course} course!"
course_name = "Digital Marketing"
congratulator = Congratulator(course_name)
print(congratulator.congratulate())

Метод 7. Использование поиска по словарю

courses = {
    "CS50": "Computer Science",
    "MATH101": "Mathematics",
    "ENG101": "English Composition"
}
course_code = "CS50"
print("Congratulations on completing the " + courses[course_code] + " course!")