Python #4 : Playing With Print Functions (Core Programming)

        


Playing with print() function in Python.

Hey! Welcome to Python Series #4:  Today, we will be learning about one of the most important functions called print function which is very important in the core programming of the Python language. Also please check the previous posts below.

Previous Posts:    Python #1: Introduction To Python Programming

                            Python #2: Installing Python In Mobiles

                            Python #3: Installing Famous Python Editors Used For Core Programming 

Introduction -  Most of you people have heard the first program of python you write is “Hello world” it is effortless to do this program to run this. There is a function called print() function. Now, let us see how to use the print function and write your program “Hello world.’


print (): Print function looks like this, followed by the word number or integer you have printed. Let's look at an example of how to print “Hello world.”


  •  For this, first, we have to type the function. As shown below 

  • In the middle of double quotes, you can insert the thing you want to print.

  • We have to print “Hello world,” so we will insert “Hello world” as shown

below

  • When we click on the run, it will print Hello world for me, as shown below. 


  • You can also print integers and many more things. Let us see examples of it in the below image.



Now let us print some Url Example:- www.google.com

Just in your code, replace Hello world with www.google.com



Now let us print the values stored in our variables 

Let us take a = 10, b = 2 

Noe let us print the value of a and b and also add it. 


  • Let us store the values in our variables. 

In this way, we have successfully saved our values in a and b


  • Now, let’s print the value of a



So as you can see, we can print the value of a very easily. 


We are not going to put double quotes “ to print the value of any variable.



  • Now let us add the value of a and b. For this, we are simply going to insert type print(“a + b”) as shown below, and it will give us the value of a + b.



Conclusion - congratulations till here you have learned the following 


  • What is a print function?

  • How to use the print function.

  • Essential addition using the print function.


In the next part, we will discuss data types, string manipulation, and other things in python. (series#5)



LinkedIn: Yaakulya Sabbani | Ethical Hacker, Bug Hunter

DM me if any queries or help required :) Thank you!


Instagram: Swaraj | Blogger

To explore more posts...


Contributions: Yasin (Technical Supporter & Content Creator)


Continued in series #4...

                                                                         










 













































































































































( extra part ) don’t use this in the current print function blog 







Now let us see what will happen if we write Print(“Hello world”) instead of print(“Hello world”). Most of you currently cant understand the difference now but first, look at the result.



As you can see, it gives an error; basically, it’s a ‘Name error.’


This error is - Python is a case-sensitive language because we inserted the line Print(“Hello world”). It gives us a mistake because the letter P in the print function was capital, and it. 


































*Always remember python is case sensitive language. If you capitalise the word, which shouldn’t be, the whole code won’t work.

  


Subscribe for our Newsletter

RE-IMAGINING THE WAY
Back to top