--Originally published at Hector Martinez Alcantara
Hey there, i’m going to explain how the basic inputs and outputs of text work.
Example of a basic input and output:
x=input('Type something\n') print('You've typed '+x+'!')
Which result is:
Type something >>>typing something You've typed typing something!
The most basic form you can make an input for basic text is with the reserved word input, this function receives a string(an array of characters), assign it to a variable, and prints a message on the screen.
syntax of an input:
variable=input('A message you want to show')
Then the most basic form you can show the value of a variable is with the reserved word print, the function print will convert every type of variable to a string and will show that string on the screen.
With the function print you can show text on screen, or a composed message of text and a variable.
here the syntax of an output:
print('The message you want to show') #Shows only the text between '' print(variable) #Shows the value of 'variable'
Suposing that variable have a value of 10 integer the output will be:
>>>The message you want to show >>>10
To show a message composed of text and a value of a variable you’ll type:
print ('First part '+ variable +' last part') #Shows a composed message of text
The text binds with the variable using the operator ‘+’ and makes only one string like the result below.
>>>First part 10 last part
Special thanks to Output and input in python