Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Input User Information

In this exercise, we will have the user enter their information and output it in a certain format.

This exercise expands upon the Print Values exercise from before. This time, we’re only going to get 2 values from the user. The first is their name and the second is their age.

Task

  • Create a name variable that simply asks the user to input their name.
  • Create an age variable that asks the user to input their age.
  • Print out the variables with the following format:
Hello {name}
I see that you are {age} years old!

Where {name} and {age} are the values from your input.

Example output

Enter your name: Edward
Enter your age: 25

Hello Edward
I see that you are 25 years old!