Print Function in python
Print Function in python
Hello Friends, I am Nirav. And in this tutorial I going to
show you how to use print function in python….
So, Let’s get Started
So, Friends as you all know print function is basic function
in any programming language.
Why we use print Function?
So,
main question is that “why we use print function?” when you wants to print
something at a time of execution of your program than you have to use print
function.
For EX:- you want to print “This is my first program” so you
have to write “This is my first program” in print function
How to treat data type in print function
In
other programming language whatever you write in print function it’s trite that
as a string and print whatever you write in print function.
But in
python in side print function it’s not trite only as a string but it’s provide
functionality that if you type integer value in print function than it’s trite
as a integer value
How to use print in python
There are mainly three ways to define print function
1.
print(“This is my first program”)
2.
print(‘This is my first program’)
3.
print(10)
In 1st it’s trite as a string as well as in 2nd
also it’s trite as a string but in 3rd it’s trite as a integer, Because, there are no any
single or double invotedcoma. So, what ever you type in single or double
invotedcoma It’s trite as a string. Other wise it’s trite as a integer.
In upper problem with print(‘This is my first program’) is
that when you write something that contain single invotedcoma
For EX:- print(‘I’m Programmer’)
So hear you have to write in double invotedcoma
For EX:- print(“I’m Programmer”)
Than it will don’t give an error.
This will give an error
How to find what’s the type of whatever you write in print function
It’s so simple to find what the type inside print function
with using type() method.
For ex.
As you shown in photo in bellow section you find out data
type of given values in print function.
Direct arithmetic operation in python
In other programming language if we
want to perform arithmetic operation than first define variables and then after
perform operations. But in python they provides direct arithmetic operations
without define any variables.
For EX:-
What if you multiply integer and string ?
As you
know in other programming language if we multiply integer and string than it’s
gives an error. Because, multiplication of string and integer is not possible.
But in python it’s possible
For EX:-
Addition of integer & integer or string &string
You also visit my youtube video regarding to this Topic
https://youtu.be/jY9Gtp9KiGQ
Comments
Post a Comment