Working with Python String Expressions in Python Notebooks in a Fabric Lakehouse is pretty straightforward, you can use the double quote (“) or single quote (‘) to enclose text and if you want to concatenate two strings you can use the “+” symbol.

firstName = "John"
lastName = 'Doe'
fullName = firstName + " " + lastName       # "John Doe"

There are lots of handy functions (Methods) you can apply to a string like lower, upper, find and replace. For a complete overview of all String Methods: Python String Methods (w3schools.com).

print( firstName.upper() )                  # "JOHN"
print( firstName.lower() )                  # "john"
print( fullName.find("Doe") )               # 5
print( fullName.find("Done") )              # -1
print( fullName.replace("John", "Jane") )   # "Jane Doe"

If you want to get a specific character or substring you can use the square brackets and get a character using the index (0 based).

print( firstName[0] )                       # J
print( firstName[0:3] )                     # Joh
print( firstName[-1] )                      # n
length = len(firstName)                     # 4

If you want to use a single quote (‘) in the text you can either use double quotes as string terminators or you can use the escape character \.

print( "It's raining" )                     # It's raining
print( 'It\'s raining' )                    # It's raining 

But what if you want to use the \ itself in a string? Then you can either use \\ or you can create a raw string.

# Use \ in String => \\ 
print( "c:\\Data\\Orders.csv")              # c:\Data\Orders.csv  
print( "xtreme\\" + firstName.lower() )     # Xtreme\john 

# Use \ in String => r (Raw string) 
print( r"\\ServerX\ShareY\Orders.csv")      # \\ServerX\ShareY\Orders.csv

print( r"\\ServerX\ShareY\")                # Wrong: may not end with  \
print( r"\\ServerX\ShareY\\")               # Correct: \\ServerX\ShareY\

#print( r"xtreme\" + firstName.lower() )     # Wrong: may not end with 

To embed variables inside strings you can use a format string (f-string).

# f-strings 
print( fr"xtreme\{firstName.lower()}" )              # Xtreme\john 
message = f"Hello {firstName},\n\tHave a good day!"  # Hello John, 
                                                     #  Have a good day!
messageMultiLine = f"""Hello {firstName}, 	
	Have a good day!
"""