Python Essentials Classroom Series – 17/Sept/2021

Exercise

  • Try to solve the problem Refer Here without using sort but you are allowed to use max
numbers = [1,2,3,4,5,6,6,7,7,8,9,9]

# Removed Duplicates and large number to create a new list
large = max(numbers)
numbers_unique = []
[numbers_unique.append(number)  for number in numbers if (number not in numbers_unique and number != large )]

# Now print the max value
large = max(numbers_unique)
print(large)

Dictionaries

  • A dictionary can hold multiple key and its associtate value
  • The key is often a string but can be any of pythons immutable types: boolean, int, float, tuple, string
  • Dictionaries are mutable
  • Refer Here for the examplse with dictionary

Leave a Comment

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

About learningthoughtsadmin