In Python, we use the print() function to display variables and their values.
1. Printing a Single Variable
2. Printing Multiple Variables
3. Printing Text with Variables
4. Using the + Operator with Strings
Note: We added spaces after "Python " and "is ". If we do not add spaces, the output will be:
Pythonisawesome
5. Using the + Operator with Numbers
Here, + works as a mathematical operator and adds the two numbers.
6. Mixing Strings and Numbers (Important)
If you try to use + with a string variable and a number variable, Python raises an error.
Example:
This happens because Python cannot add a number and a string using +.
To correctly output different data types together, use a comma (,) instead.
Example: