Python: print() methods
17 July 2024 at 10:58
Hi all,
Today, I learned about the Python print statement. It is fascinating to know that Python has so much functionality.I will share some of the thing i learned today
- sep, the sep parameter is used with the print() function to specify the separator between multiple arguments when they are printed.
- escape sequence like \n (new line), \t(adds space), \b(removes previous character).
- concatenation which adds two different strings.
- concatenating str and int which combine string and integer by converting integer into string by typecasting.
- Raw string A raw string in Python is defined by prefixing the string literal with an 'r' or 'R'.Raw strings are often used when working with regular expressions or when dealing with paths in file systems to avoid unintended interpretation of escape sequences.
- Format the format() method is used to format strings by replacing placeholders {} in the string with values passed as arguments.
-
string multiplication here you can multiply strings by using the
*
operator. This operation allows you to multiply string a specified number of times.