Getting started with PYTHON!!! #1 - Print Statement

Getting started with PYTHON!!!
    #1 - Print Statement

Hello People , here's some information needed for you peeps to know before getting started with PYTHON .

Python is a interpreted language which compiles and executes the code in place of a CPU (the code is compiled line by line and gives you instant error along with the line number if there is some mistake in a particular line and stops execution then and there)

So, here is a basic code for printing Hello World! in python
print(" Hello World ! ")

online compiler for you to run the above code.

the keyword print(" ") is used for printing a string in python.

The keyword print() has 5 parameters , namely:

  • object
  • separator
  • end
  • file -flush

print(*objects, sep=" ", end="\n", file=)sys.stdout, flush=False)

*objects - Whatever objects you want to print on the screen , objects is prefixed with a asterix(*) which means we can pass as many objects as we want through the print function.
print("there", "are" , 4 , "objects in this print statement")

Screenshot from 2022-01-31 18-13-14.png

sep- sep stands for separator, this parameter is used to separate different objects within the same print statement . It has a default value as space.
print("objects of same print statement separated using @", sep="@")

Screenshot from 2022-01-31 18-14-29.png

end - This is used to format the starting position of the next print statement . This decides how the next print statement is separated from the earlier print statement. It has a default value as Newline("\n").
print("next print statement is separated from this print statement using ##",end="##")
print("2nd print statement")

Screenshot from 2022-01-31 18-14-05.png

file - It is used to write your output to the file stream. By default, it has a value equal to sys.stdout. This means that the output will be displayed to the standard output screen, i.e., on the console.
flush - It takes either True (the stream is forcefully flushed)or False(default value) value.