Programs · Program 7-8
Q.Program 7-8: Write a program using a user defined function that accepts the first name and lastname as arguments, concatenate them to get full name and displays the output as:
Hello full name
For example, if first name is Gyan and lastname is Vardhan, the output should be:
Hello Gyan Vardhan
Uttar Pradesh UpmspTextbookSubjective· 3mImportance★★★★★est
25% · 10/40 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Program 7-8 passes two strings into a user-defined function, concatenates them with + (inserting a space), and displays the greeting Hello full name.
The idea. Function parameters carry any object type — here strings. The + operator on strings performs concatenation, and the explicit " " between the names is what produces "Gyan Vardhan" instead of "GyanVardhan".
# Program 7-8: concatenate first and last name and greet
def fullname(first, last):
full = first + " " + last
print("Hello", full)
first = input("Enter first name: ")
last = input("Enter last name: ")
fullname(first, last)
Key lines
first + " " + last— string concatenation with a literal space in the middle.print("Hello", full)—printinserts one space between its comma-separated arguments, giving exactlyHello Gyan Vardhan. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.