Python Classroom Series – 03/Sept/2020

New Style for formatting strings

  • New Style of formatting strings has the following form
format_string.format(data)

Preview

Newest style: f-string

  • f-strings are referred as format strings Preview

  • Python has two other sequence types in addition to string tuples and lists.

Tuples

  • Tuple is sequence of objects
  • Empty tuple, single element & multi-element example tuple declarations Preview
  • Tuple unpacking Preview
  • Tuple class definitions Refer Here
  • Creating with tuple() and accessing elements using indexes Preview
  • Combine tuples using +, duplicating tuples with * and comparing tuples with == Preview
  • Iterating tuples
def tuple_simple_loop():
    """
    This function demonstrates the simple tuple iterations
    """
    words = ('running', 'out', 'of', 'ideas')
    for word in words:
        print(word)

Preview

Lists

  • Lists are sequence of objects which are mutable
  • Creating with [] Preview
  • Using list() Preview
  • Other List Operations Preview Preview Preview

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin