Program:
#Defining a function which takes name and gender as input
def prefix(name,gender):
if (gender == 'M' or gender == 'm'):
print("Hello, Mr.",name)
elif (gender == 'F' or gender == 'f'):
print("Hello, Ms.",name)
else:
print("Please enter only M or F in gender")
#Asking the user to enter the name
name = input("Enter your name: ")
#Asking the user to enter the gender as M/F
gender = input("Enter your gender: M for Male, and F for Female: ")
#calling the function
prefix(name,gender)
OUTPUT:
Enter your name: John
Enter your gender: M for Male, and F for Female: M
Hello, Mr. John