Python - Print Examples
Tuesday, 25 January 2011 14:51

Below is a small example to show some of the various way in which print can be called within Python.

quote = "A person who never made a mistake never tried anything new."

print("ORINGINAL")
print(quote)

print("\nUPPERCASE")
print(quote.upper())

print("\nLOWERCASE")
print(quote.lower())

print("\nTITLE")
print(quote.title())

print("\nREPLACE")
print(quote.replace("person", "banana"))

Output

[root@linux]# python print_example.py
ORINGINAL
A person who never made a mistake never tried anything new.

UPPERCASE
A PERSON WHO NEVER MADE A MISTAKE NEVER TRIED ANYTHING NEW.

LOWERCASE
a person who never made a mistake never tried anything new.

TITLE
A Person Who Never Made A Mistake Never Tried Anything New.

REPLACE
A banana who never made a mistake never tried anything new.

[root@Fileserver python]# python string_manip.py


 
We have 25 guests online