ou are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:Hello firstname lastname! You just delved into python.
Question
ou are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:Hello firstname lastname! You just delved into python.
Solution
Sure, here is a simple Python code that reads first name and last name from user input and prints the required message:
# Read first name
firstname = input()
# Read last name
lastname = input()
# Print the message
print("Hello " + firstname + " " + lastname + "! You just delved into python.")
This code works as follows:
- The
input()function is used to read a line of text from the user. This is done twice to read the first name and the last name separately. - The
print()function is used to print the required message. The "+" operator is used to concatenate the strings together.
Similar Questions
Write a Python program that inputs a user's first and last name and prints them in reverse order with a space in between.For example, if the program inputs the first name "Joe" and the last name "Bakers," it should output:Bakers Joe
Write a function in Python to read a text file, Alpha.txt and displaysthose lines which begin with the word ‘You’
What is the output of the Python code below?s = "help"for letter in s[1:]: last = letter breakprint(last)Question 2Select one:a.hb.ec.!d.pe.lClear my choice
Get the characters:From: "o" in "World!" (position -5)To, but not included: "d" in "World!" (position -2):b = "Hello, World!"print(b[-5:-2])Try it Yourself »
Write a python program to take full name of 2 users separately(name 1 and name 2), and print the number of letters in name 1, then printname 2 number of times equal to the number of letters in name 1.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.