• fstring help
  • Round to a decimal place
    number = 5.75253545
    print(f'{number:.2f}')
    >>>5.75
  • Leading zeroes
    number = 4
    print(f'{number:03d}')
    >>>004
  • Alignment
    print(f'{"apple" : >30}')
    print(f'{"apple" : <30}')
    print(f'{"apple": <30} banana')
    print(f'{"apple" : ^30}')
  • Currency
    large_number = 126783.6457
    print(f'Currency format for large_number with two decimal places: ${large_number:.2f}')

>>> Currency format for large_number with two decimal places: $126783.65

  • Comma Separators
    large_number = 126783.6457
    print(f'Currency format for large_number with two decimal places and comma seperators: ${large_number:,.2f}')

>>> Currency format for large_number with two decimal places and comma seperators: $126,783.65

List ( a Collection datatype )

  • Next class will start to cover in detail
  • list is an ordered sequence of elements
  • a list is changable; meaning can change, add or remove elements
    • enclosed by []
    • seperate by commas
    • declare list by
      • []
      • list()
lst = [1, 1.23, True, 'hello', None]
print(lst)
>>>
[1, 1.23, True, 'hello', None]
lst = list((1, 1.23, True, 'hello', None)) # notice the double round brackets
print(lst)
print(len(list))
print(lst[0])

>>>
[1, 1.23, True, 'hello', None]
5
1