Python tutorial 19: Python Print function With Example By Manish Sharma

Manish Sharma · Beginner ·🛠️ AI Tools & Apps ·7y ago

Key Takeaways

Explains the Python print function with examples, covering its syntax and usage

Full Transcript

we have been using this function since the very first tutorial of this series but never talked about it so let's discuss it today who's over the net i am manish from rebellionrider.com and i am back once again with another awesome python tutorial in today's video we will learn the concept of Python print function with easy examples but before we start give this video a thumbs up also help me in reaching 100k subscribers by subscribing to my channel if you haven't already now let's start Python print is a simple program which displays text back to the user on the standard output string print used to be a statement in Python 2 but with the launch of Python 3 this became a function in Python 2 if we have to display a string back to the user we have to write the print statement something like this but this will not work if you are using the latest version of Python which is Python 3 you will get a syntax error something like this this is because Python print is no longer a statement in Python 3 this has become a function and we have to call it in a proper function way where we have a function name along with parentheses which are holding some arguments something like this except from added parentheses everything is pretty much the same Python print function call which you are watching right now on your screen is the only valid function call in Python 3 that is just the introduction now let's start the tutorial the Python print function called we have seen or written so far in this entire series of running pretty much on default settings you can override these default settings and do certain amount of formatting with your output if you know the syntax so let us check out the syntax right on your screen is the syntax of Python print function this simple looking print function takes five arguments let's see what these are object object is something you want to display back to the user on in standard output stream it could be a string an integer value drive from an expression on anything furthermore you can use a single Python print function call to show more than one object at once let me show you let's first closes output panel and clear the screen great okay in this statement the string was of Internet is the object in this function call we used only one object which is the mentioned string but we can use single Python print function call to display more than one object like there's here we have a single print function call but using that we are showing two string objects to the user on execution both these objects will be printed on the screen separated by a blank space let's see here I mentioned blank space for a reason I'll explain to you in a second but for now let's concentrate here in order to take advantage of other parameters of the print function call make sure to separate all the objects using commas if you want you can ditch the comma there will be no problem as long as the object you are displaying is a string let me show you what happens if there is no comma let's execute and see the result as you can see although the Python print function displayed the result but not in the proper manner we have both the objects printed but the blank space in between which was separating them is missing here the print function concatenated put these strings into each other before displaying it to you now what if the objects were mathematical expressions instead of a string will skipping a comma still work let's see here I have Python print function call containing two simple mathematical expressions both these expressions are separated by a comma let's execute and see the result here we got a valid output five plus five evaluated into ten and two into two evaluated into four now let's delete the coma and see what happens let's execute again we got a syntax error Python interpreter usually evaluates the mathematical expressions specified in print function call and then print their result here to our eyes we have two expressions but for Python interpreter there is only one expression which is missing a mathematical operator between them hence we have this error now let's come back to our syntax the next argument is slap zap is an acronym for separator this is the string which will get pleased between two objects we just saw it's example when we specified two string objects separated by comma then as a result we caught both these strings printer and both are separated by a blank space the default value of sap is set to blank space that is why both the objects in our example were printed with a blank space between them we can change this default value let's say I want my objects to be separated by something else than a blank space let's see how we can do that let's close this output panel and clear the screen first done if we execute this print function call now then both these strings will get printed with a blank space between them in the result now let's override the default setting now if we execute this print statement then both these string objects will get printed but this time the separator which will be placed between them will not be a blank space rather it will be a triplet of greater than sign to change the separator firstly you have to put a comma after your objects then you have to write the keyword zap mind here the keyword zap is case-sensitive which is why you have to make sure that it must be written in all small letters followed by the keyword you have to specify your desired string which you want to place between the objects this string must be enclosed inside a pair of code it could be a single good or a double code let's execute this Python print function call and see the result as you can see this time both these strings are separated by a triplet of greater than sign instead of blank space except from strings you can also specify escape sequences such as slash end for new line or slash T for a tab let's modify this print statement and change the separator string with slash T done now in execution a horizontal tab will separate both these string objects instead of a single space let's execute and check here is the desired result now let's see what is the third parameter on the list the third parameter of Python print function is and and is again a string which gets inserted at the end of the compile the text of Python print function call by compile to text I mean the end result derived either after evaluating the expression or processing the objects like integer or string by default it is set on slash and escape sequence which is an indicator for the next line let's see what exactly does it mean let's close this output panel and clear the screen by the way if you want the code which I showed you in this tutorial for practice then you can always head over to my blog link is in the description here I have two consecutive Python print function calls first one contains a mathematical expression while the second one contains a string now let's execute and see how the output will come here we got the output the result of the expression is printed in the first line and then the string in the next line the output of the second print function call is printed in a new line that is because of the default behavior of the end parameter now let's override this default behavior and see if we can display the output of two different print functions in the same line here is our first print function call I will modify it and chase a value of and parameter from slash n to slash T done as you can see I have changed the value of n parameter in the first statement from slash n to slash T because of that the interpreter will not jump to a new line for printing the output of the consecutive statement rather it will print the output from the following statement in the same line because of this slash t escape sequence it will separate the output of both these statements with a horizontal tab let's execute and see here is the output in the modified format great now let's see what is the next parameter in the syntax of Python print function the next two parameters are file and flash in order to discuss these two parameters we need to do a separate tutorial that way we can keep things confusion free therefore I will cover them in the next tutorial anyways please do read the corresponding blog for more in-depth knowledge of the topic link is in the description hope this video helped you in learning the concepts of Python print function if you enjoyed watching please give this video a thumbs up and share it with your friends most importantly subscribe to the channel if you haven't already thanks for watching this is Manish from rebellion writer calm

Original Description

A detailed Python Tutorial explaining how to bring the best out of python PRINT function with simple Examples. Learn Python 3 in 2019 by Manish Sharma From RebellionRider.com ------------------------------------------------------------------------ ►►►LINKS◄◄◄ Blog: http://www.rebellionrider.com/how-to-bring-the-best-out-of-python-print/ Previous Tutorial ► Python Slice https://youtu.be/BXUBso78-RQ ------------------------------------------------------------------------- ►Make sure you SUBSCRIBE and be the 1st one to see my videos! ------------------------------------------------------------------------- ►►►Find me on Social Media◄◄◄ Follow What I am up to as it happens on https://www.facebook.com/TheRebellionRider/ https://twitter.com/rebellionrider http://instagram.com/rebellionrider https://plus.google.com/+Rebellionrider http://in.linkedin.com/in/mannbhardwaj/ You can also Email me at for E-mail address please check the About section Please please LIKE and SHARE my videos it makes me happy. Thanks for liking, commenting, sharing and watching more of our videos This is Manish from RebellionRider.com ♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS #PythonWithRebellionRider
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Manish Sharma · Manish Sharma · 0 of 60

← Previous Next →
1 Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Manish Sharma
2 Oracle Database tutorials 2:How To install SQL Developer on windows 7
Oracle Database tutorials 2:How To install SQL Developer on windows 7
Manish Sharma
3 Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Manish Sharma
4 Oracle Database tutorials 4:  database connectivity using SQL developer and command prompt
Oracle Database tutorials 4: database connectivity using SQL developer and command prompt
Manish Sharma
5 Oracle Database tutorials 5:  how to Fetch Data using SELECT - SQL statement by Manish Sharma
Oracle Database tutorials 5: how to Fetch Data using SELECT - SQL statement by Manish Sharma
Manish Sharma
6 Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Manish Sharma
7 Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Manish Sharma
8 Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Manish Sharma
9 First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE  - ORACLE DATABASE ADMINISTRATOR
First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
10 Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Manish Sharma
11 Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Manish Sharma
12 Oracle Database11g tutorials 10 ||  SQL Single Row Function (SQL Functions )
Oracle Database11g tutorials 10 || SQL Single Row Function (SQL Functions )
Manish Sharma
13 Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Manish Sharma
14 how to add channel trailer and section on your youtube channel 2014
how to add channel trailer and section on your youtube channel 2014
Manish Sharma
15 Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Manish Sharma
16 Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Manish Sharma
17 Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Manish Sharma
18 SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
Manish Sharma
19 Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Manish Sharma
20 ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look  - ORACLE DATABASE ADMINISTRATOR
ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
21 Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Manish Sharma
22 SQL tutorials 17: SQL Primary Key constraint,  Drop primary Key
SQL tutorials 17: SQL Primary Key constraint, Drop primary Key
Manish Sharma
23 SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
Manish Sharma
24 SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
25 SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
26 SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
Manish Sharma
27 SQL tutorial 22: How to Add / Delete column from an existing table using alter table
SQL tutorial 22: How to Add / Delete column from an existing table using alter table
Manish Sharma
28 SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
Manish Sharma
29 SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
Manish Sharma
30 Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Manish Sharma
31 SQL tutorial 26: Introduction to SQL Joins in Oracle Database
SQL tutorial 26: Introduction to SQL Joins in Oracle Database
Manish Sharma
32 Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Manish Sharma
33 SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
Manish Sharma
34 SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
Manish Sharma
35 SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
Manish Sharma
36 SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
Manish Sharma
37 SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
Manish Sharma
38 SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
Manish Sharma
39 SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
Manish Sharma
40 SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
Manish Sharma
41 SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
Manish Sharma
42 SQL tutorial 36: how to create database using database configuration assistant DBCA
SQL tutorial 36: how to create database using database configuration assistant DBCA
Manish Sharma
43 SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
Manish Sharma
44 SQL tutorial 38: How to create user using SQL Developer in Oracle database
SQL tutorial 38: How to create user using SQL Developer in Oracle database
Manish Sharma
45 SQL tutorial 39: How to create user in oracle using Enterprise Manager
SQL tutorial 39: How to create user in oracle using Enterprise Manager
Manish Sharma
46 SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
Manish Sharma
47 Motorola Moto G 2nd Generation / G2 Unboxing and Review
Motorola Moto G 2nd Generation / G2 Unboxing and Review
Manish Sharma
48 SQL tutorial 41: How to UNLOCK USER in oracle Database
SQL tutorial 41: How to UNLOCK USER in oracle Database
Manish Sharma
49 SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
Manish Sharma
50 SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
Manish Sharma
51 SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
Manish Sharma
52 SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
Manish Sharma
53 SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
Manish Sharma
54 SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
Manish Sharma
55 SQL tutorial 48: How to create Roles in Oracle Database
SQL tutorial 48: How to create Roles in Oracle Database
Manish Sharma
56 SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
Manish Sharma
57 SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
Manish Sharma
58 SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
Manish Sharma
59 Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Manish Sharma
60 Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Manish Sharma

Related AI Lessons

Up next
How to Open HPL Files (HP-GL Plotter)
File Extension Geeks
Watch →