How to use print function in Python.

Definition and Usage

The print() function prints the specified message to the screen, or other standard output device.
The message can be a string, or any other object, the object will be converted into a string before written to the screen.

Syntax:-

print(object(s), separator=separator, end=end, file=file, flush=flush)

Examples :


  1. print("hello world")


  2. print("line A nline B")
  3. print("line an line bn line c")
  4. print('line "a" n line "b"')
  5. print("/\ /\\ //\ ")
  6. name,age=input("enter value a and b:").split(",")
    name=int(name)
    age=int(age)
    print(age+name)
  7. print(2**3)
  8. def varar(d):
    print(d)
    no=5

OUTPUT

"C:UsersuserPython EXhelloworldvenvScriptspython.exe" "C:/Users/user/Python EX/helloworld/printFunction.py" hello world
....................
line A line B
...... .....................line a line b line c
.........................line "a" line "b"
......................... / /\ //
..............................enter value a and b:4,5 9 8 5 Process finished with exit code 0

Leave a Comment

Your email address will not be published. Required fields are marked *