Computer programs use variables to hold and work with values in memory. For this reason it's important to know a little bit more about them.
This sample shows how to print a calculated value to the user
myNumber = 2 print(myNumber)
Most of the time, the program will wait or ask the user to input values. To do this with python is very simple. We'll use input() function for that.
myNumber = input("Enter a number: ") print(myNumber)
Using this code below, the program will wait for a value from the user.
myName = input("Enter your name") print(myName)
The issue here is that the user's response will be concatenated directly with the question.
To solve that, we can use escape characters to insert a new line \n.
myName = input("Enter your name\n") print(myName)
Now, the question will be showed in one line and the answer in another one.
You can access this code on github.
If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. If you feel comfortable with github, instead of posting a comment, please go directly to https://github.com/campelo/documentation and open a new pull request with your changes.