Posted at: https://laptrinhcanban.com/en
Instructions on how to input variables into python . You will learn how to input a variable’s value from a keyboard using the inpput() function in python after this lesson.
Input variables into python
To import variables in python we need to use a built-in function called inpput () function in python .
The input () function will help us enter input from the keyboard and assign that value to the variable with the following syntax:
variable
= input
()
Inside:
input
used to call the function. When the function is called, an input line will appear so that the user can input from the keyboard.variable
is set according to the Python Variable Naming Rule that you learned in the article What is Variable in Python.
After the user can input from the keyboard, the input string will be assigned variable as the string data type.
You can also use the following syntax to make the input screen more beautiful:
variable
= input
(">>"
)
For example, we have a program to enter the name and print it to the screen as follows:
print ( "Please enter your name :" ) |
Save the above program as user.py and run it on Anaconda Prompt. The result will be as follows:
Summary
Above, Kiyoshi explained how to import variables in python. To better understand the lesson content, practice rewriting today’s examples.
And let’s learn more about Python in the next lessons.
URL Link
HOME › python for beginners>>variables in python