# Import the string module to get all the in-built helper methods for string
import string
# Case change of string variables
name = "jennifEr loves Python"
# Title case
name_t = name.title()
print (name_t)
# Upper case
name_t = name.upper()
print (name_t)
# Lower case
name_t = name.lower()
print (name_t)
# String Concatenation
fname = "jennifer"
lname = "python"
flname = fname + " " + lname
print (fname + " " + lname)
print ("Jennifer" + " " + "Python")
# OR equivalently
print (flname.title())
# Adding WhiteSpaces
print ("Jen\nloves\npython")
print ("Jen\tloves\tpython")
print ("Jen\tloves\npython")
# Stripping Whitespace
name1 = " Jennifer"
name2 = "Jennifer "
name3 = " Jennifer "
print (name1)
print (name2)
print (name3)
print ("----------")
print (name1.lstrip()) # lstrip() takes all extra whitespaces from left
print (name2.rstrip()) # rstrip() takes all extra whitespaces from right
print (name3.strip()) # strip() takes all extra whitespaces from both left and right
# str() -> casts other data types to string
jensage = 21
# print ("Jennifer's age is " + jensage) ## This is an error as one cannot concatenate string and integer
print ("Jennifer's age is " + str(jensage)) # This works!
# Lists, Dictionaries, Tuples and other objects can be casted to String
l_langs = ["Python", "R", "Julia"] # List
t_langs = ("Python", "R", "Julia") # Tuple
d_langs = {1: "Python", 2: "R", 3: "Julia"} # Dictionary
print ("This is a list: " + str(l_langs))
print ("This is a tuple: " + str(t_langs))
print ("This is a dictionary: " + str(d_langs))
# Some helpful constants built-in the string module
print ("All Letters: " + string.ascii_letters)
print ("Lowecase: " + string.ascii_lowercase)
print ("Uppercase: " + string.ascii_uppercase)
print ("Punctuations: " + string.punctuation)
print ("Numbers: " + string.digits)
print ("Hex Digits: " + string.hexdigits)
print ("Oct Digits: " + string.octdigits)
print ("Whitespace: " + string.whitespace)
print ("Printable: " + string.printable)