Important Notice:

Printing Output (print())

Printing Output (print())

3 views 2 min read

Printing Output (print()) :-

print() Python का एक Built-in Function है, जिसका उपयोग स्क्रीन (Console) पर Output (परिणाम) प्रदर्शित करने के लिए किया जाता है। इसकी सहायता से String, Number, Boolean, Variables, Expressions तथा विभिन्न प्रकार के Data को आसानी से प्रदर्शित किया जा सकता है। print() Function Program के Execution के दौरान परिणाम (Output) को User तक पहुँचाने का सबसे सामान्य और महत्वपूर्ण माध्यम है।

English:
print() is a built-in Python function used to display output on the screen (console). It can print strings, numbers, booleans, variables, expressions, and different types of data. The print() function is the most common and important way to display the output of a program to the user during program execution.

Example 1: Printing a String -

print("Hello World")

Output

Hello World

Example 2: Printing an Integer -

print(100)

Output

100

Example 3: Printing a Float -

print(99.5)

Output

99.5

Example 4: Printing a Boolean Value -

print(True)
print(False)

Output

True
False

Example 5: Printing a Variable -

name = "Rahul"

print(name)

Output

Rahul

Example 6: Printing Multiple Variables -

name = "Rahul"
age = 18

print(name, age)

Output

Rahul 18

Example 7: Printing Multiple Values -

print("Rahul", 18, True, 95.5)

Output

Rahul 18 True 95.5

Example 8: Printing an Expression -

a = 10
b = 20
print(a + b)

Output

30

Example 9: Printing the Result of Multiplication -

a = 10
b = 5
print(a * b)

Output

50

Example 10: Printing a List -

numbers = [10, 20, 30]

print(numbers)

Output

[10, 20, 30]

Example 11: Printing a Tuple -

data = (10, 20, 30)

print(data)

Output

(10, 20, 30)

Example 12: Printing a Dictionary -

student = {
    "name": "Rahul",
    "age": 18
}

print(student)

Output

{'name': 'Rahul', 'age': 18}

Example 13: Printing a Set -

colors = {"Red", "Green", "Blue"}

print(colors)

Output

{'Red', 'Green', 'Blue'}

Example 14: Printing Using sep -

sep (Separator) Parameter का उपयोग print() Function में एक से अधिक Values के बीच Separator (विभाजक) निर्धारित करने के लिए किया जाता है। यदि sep नहीं दिया जाता, तो Python By Default एक Space ( ) का उपयोग करता है।

English:
The sep (separator) parameter is used in the print() function to specify the separator between multiple values. If sep is not provided, Python uses a space ( ) as the default separator.

Example-

print("Python", "Java", "C++", sep="-")

Output -

Python-Java-C++

Example 15: Printing Using end -

end Parameter का उपयोग print() Function में यह निर्धारित करने के लिए किया जाता है कि Output के अंत में क्या Print होगा। यदि end नहीं दिया जाता, तो Python By Default New Line (\n) का उपयोग करता है, जिससे अगला print() नई पंक्ति से शुरू होता है।

English:
The end parameter is used in the print() function to specify what should be printed at the end of the output. If end is not provided, Python uses New Line (\n) by default, so the next print() starts on a new line.

Example-1

print("Hello", end=" ")
print("World")
 
Output -
Hello World
 
Example- 2
print("Hello", end=" ")
print("World")
 
Output -
Hello World
 
Example 3: Using Tab (\t) as end-
print("Name", end="\t")
print("Rahul")

Output -

Name    Rahul

 

Related Notes