Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The print function
Variables
Math in Python
The input function
18. input() function
Summary

Instruction

Good job! Now, let's find out how to make our programs interactive by accepting user input. Take a look:

age = input('What is your age? ')
print('You are', age, 'years old.')

We introduced a new function: input(). input() asks the user to provide some data by providing the prompt as an argument inside the parentheses. We can then print the input using print().

Exercise

Create one variable: name. Write a program that will ask the user for their name. Ask the following question: What is your name?

Then, greet the user with their name: Hello {name}

Here, {name} should be substituted for the value entered by the user. For example, if the user's name is Alex, your program should print:

Hello Alex

Stuck? Here's a hint!

Use input(...) to get the values from the user. Finally, use print to show the following sentence:

Hello {name}