Python Print() Function
Since we have downloaded, installed, and setup the Python IDLE in our machine. That means we are now ready to write our first program in Python. To do so we will learn the working of Python print() function.
Your First Program in Python
Python print() function is used to print the messages (A single word, sentence or paragraph), value(s) of variable(s), etc.
Example 1: Printing Hello Word in Python.
Steps to print Hello word in Python.
- Open the Python IDLE.
- Now type print(“Hello”); and hit enter.
- The hello word will be displayed on the python IDLE.
Example 2: Printing any message in Python.
Program: print("Hello world I am learning Python with the help of this free Python Tutorial"); Output: Hello world I am learning Python with the help of this free Python Tutorial
Example 3: Printing the value of variable.
Program: a=2; print(a); Output: 2
Note: Since the Python Print() function prints the text as it is written within the double quotes, so in order to print the value of a variable just pass the name of the variable as the argument of print() function.
Example 4: Write a python program to add two numbers.
Program: a=2; b=4; c=a+b; print(c); Output: 6
Example 5: Write a python program to add two numbers and print the value of summation along with some text message.
Program: a=2; b=4; c=a+b; print("Summation of",a,"and",b,"is equal to",c); Output: Summation of 2 and 4 is equal to 6
This Python tutorial is designed to help the beginners as well as the professional developers. For better understanding the language of the tutorial is kept simple and easy to understand.
This tutorial demands to have the basic knowledge of the programming languages such as c or c++ for the better understanding of the Python programming. The other basic requirement to learn Python through this tutorial is the basic knowledge of computer and information technology so you can easily acquire a better understanding Python programming.
In case you find any kind of error like typing error, spelling mistakes, incorrect grammar, incorrect information or any other mistakes. Please feel free to write to us at: firstname.lastname@example.org.