Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please modify this Python code according to instructions: firstName = input(Enter your first name: ) lastName = input(Enter your last name: ) birthYear = input(Enter
Please modify this Python code according to instructions:
firstName = input("Enter your first name: ") lastName = input("Enter your last name: ") birthYear = input("Enter your birth year: ") currentYear = input("Enter the current year: ") fullName = firstName + " " + lastName age = int(currentYear) - int(birthYear) print("Hello " + fullName + ". You are",age, "years old.")
Instructions:
-
- Use the string.join() function to combine firstName and lastName (instead of using the + symbol)
- hint: youll have to modify the initialization value of fullname
- Use the string.join() function to combine firstName and lastName (instead of using the + symbol)
- Add the following code after your last line of code.
- Create a new string variable called helloStmnt that holds the value of your previous print function
- hint: the one that prints Hello [fullname]. You are [age] years old.
- Create a new list variable called stmntList using the split()function on the variable helloStmnt
- Print Your first name is [first name from the new stmntList list]
- hint: you will have to reference the position in the list to get the first name
- Create a new string variable called helloStmnt that holds the value of your previous print function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started