Computer Science Of Engineering

Simple and practical computer science tutorials, programming guides, and engineering concepts for students and beginners.

Breaking

Thursday, April 24, 2025

Write a python program to define a function using default arguments.

 def greet(name="Guest", message="Welcome to our website!"):

    print("Hello", name + "!")

    print(message)


# Calling the function in different ways

greet()  # uses both default values

greet("Sai")  # overrides only the 'name'

greet("Kiran", "Have a great day!")  # overrides both

Output:

No comments:

Post a Comment