DEV Community

technonotes-hacker
technonotes-hacker

Posted on

Python - Print ()

Image description

Print()

  • This is a function.
  • Whatever you declare inside the print , it will be printed.
  • Any number strings can be given inside.

Eg.,

Image description

  • If there is a function then you can send n number of parameters.
  • what is parameter here ? (a & b are the parameter ,its an example)

Image description

  • sep ---> separator
  • default value of sep is space , so you can see a space in the above screenshot result.

Image description

  • printing to next line

Image description

  • horizontal tab

Image description

String concatination

  • 2 objects.
  • what is objects ? CAR --> maruti , volvo ( these are objects )

Image description

End function

  • when a sentence ends we can use that.
  • Eg.,

Image description

Escape sequence

  • see properly , these are used inside the double quotes.

Image description

Image description

Raw string

  • slashes gets changed in windows , at that time you can use this.
  • it will print whatever you give inside.
  • see carefully the examples , the slash is missing in the first output so we are using "r".

Image description

Type Casting

  • Trying to change the type of it so that it will work.

Image description

  • Changed it.

Image description

Printing quotes inside the string

Image description

Triple quotes / Multi Line Strings

  • it will print as its.
  • eg.,

Image description

String Multiplication

Image description

Format

  • variable assigment.
  • Object & Methods.
  • Object will have many methods.
  • get all methods for the object , by using below.

Image description

  • I used type casting here, but the usage of this will not be coding method but its not wrong.

Image description

  • Using method we can get the output.

Image description

  • Its taking care the typecasting on its own.

Image description

  • Using positioning or indexing we can pass the value.

Image description

F string format

Image description

Notes

  • In print statement we are using both numeric & also string --> the output will always be STRING. So in a nutshell , anything which is coming out of print statement is STRING.
  • In other words , return type of print function is STRING.
  • String will always be in double quotes.

Notable Questions

Image description

Image description

Reference

https://www.youtube.com/watch?v=zr3skBHzbAI

Top comments (0)