wereld = 'wereld'

print('hallo' + wereld) # concat
print('hallo', wereld) # concat through print function
print('hallo %s' %wereld) # %-formatting, placeholder %
print('hallo {}'.format(wereld)) # string format
print('hallo {wereld}'.format(wereld = wereld)) #string template format with named placeholder
print(f'hallo {wereld}')  # f string https://[Log in to view URL]

hallo = 'wereld'
print('hallo=', hallo) #when trying to understand a variable often some construct like this is used. since 3.8 python has a build in function for that
print(f'{hallo=}') # add = after the variable name to print both the variable name and the value. since 3.8: https://[Log in to view URL]
print(f'{hallo=:}')# add =: to print variable name and the value using str function  

print()
print('date time object example')
import datetime
datetime_object = datetime.datetime.now()
print(f'{datetime_object}')
print(f'{datetime_object=}')
print(f'{datetime_object=:}')

#So the rules are:
#{x=} -> "x="+repr(x)
#{x=:.2f} -> "x="+format(x, ".2f")
#{x=:} -> "x="+format(x, "")
#{x=:!s:20} -> "x="+format(str(x), "20")
#{x=:!r:20} -> "x="+format(repr(x), "20")

#str() is used for creating output for end user while repr() 
#is mainly used for debugging and development. repr’s goal 
#is to be unambiguous and str’s is to be readable.

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: