Introduction Of Print Function In Python
Table of Contents
The print function in the programming language prints or output the specified message which developer put in the code, it display on the screen, or other stranded output devices.
The message may be string, number, or any other object. The object will be converted into string before display on the screen. When you write user input field in print function it is highly recommended you should declare a data type first if you are writing integer, double or float For example
Syntax:
print(object (s), sep = saperator, end = end, file = file, flush = flush)
Print() Parameters:
Note:
sep, end, file, and flush are keyword arguments. If you want to use sep argument, you have to use:
print (object, sep = ‘separator’)
print (object, ‘separator’) =====> Wrong argument
Example Of Print Function In Python:
>>>print (“Hello Word”)
>>Hello Word
>>>print (25)
25
>>>print (20+ 5)
25
>>>print(“12*5 =:”, 12 * 5)
12*5 = 60
>>print (“GSS “, “TECHNOLOGY”, sep=”=========”)
GSS============= TECHNOLOGY
Access The Value of A Variable In A Print () Function:
>>>x = “Hello”
>>>print (x)
Hello
>>>x = “2,4,6,8,10”
>>>print (x)
2,4,6,8,10
>>> print (“Hello %s” % name)
Hello SADAQAT
>>> name = “Sadaqat”
>>> print (name)
Sadaqat
>>> age = 16
>>> print (“Hello %s! Are your %d years old” % (name, age))
Hello Sadaqat! Are your 16 years old
>>>
Decimal Value Limit In Print Function
Print function in python, when you write a decimal value it comes 6 digit after decimal. For example print (“marks =%f” % 90.5) the result will be 90.500000, so now we want decrease the limit after decimal. How you do it just follow this example.
>> print(“Marks = %f” % 90.5)
Marks = 90.500000>> print(“Marks = %.2f” % 90.5)
Marks = 90.50
>>>
Pingback: Top 7 Best Ideas To Make Money Online In 2020. - GSS TECHNOLOGY
I got what you intend,saved to fav, very decent web site. Henrieta Codie Gideon
Thank You for interested in my site.
Pingback: Learn Python 3.8 Online | What Is Data Science? | GSS TECHNOLOGY
Pingback: Free PHP MySQL POS With Source Code 2021 | GSS TECHNOLOGY