#There are four collection data types in the Python programming language:
#LIST
#It is a collection which is ordered and mutable(changeable) which Allows duplicate members.
#TUPLES
#It is a collection which is ordered and unmutable(unchangeable) which Allows duplicate members.
#SETS
#It is a collection which is unordered and unindexed which doesn't Allow duplicate members.
#DICTIONARY
#It is a collection which is unordered, changeable and indexed which doesn't Allow duplicate mem
#courses is list containing elements history, physics, maths and english
courses =['History' , 'Physics' , 'Maths', 'English']
courses2 = ['Art', 'Education']
#this will print the whole list
print(courses)
#you can access any element of list using index number which begins from 0.
#to print maths which is at index 2, simply write list[index_no]
print(courses[2])
#insert method is used add element at given index
#in this courses2 list is added to courses list at index 0.
courses.insert(0, courses2)
#list gets appended inside list. to avoid this we can use extend method.
print(courses)
#extend is used so list wont get appended inside list
courses =['History' , 'Physics' , 'Maths', 'English']
courses.extend(courses2)
#new list
print(courses)
#pop() removes last item and we can store it in a variable
popped= courses.pop()
print(popped)
#reverse the order using reverse method
courses.reverse()
print(courses)
#sort the list in desc order when reverse is true
courses.sort(reverse=True)
print(courses)
#sorted version of list is not reflected in original list
print(sorted(courses))
#order remains same as it was before using sorted method
print(courses)
#finding index
print(courses.index('Maths'))
#finding element in list, True if there and False is not
print('English' in courses)
#Printing each element of list
for course in courses:
print(course)
#Printing each element with index
for index, course in enumerate(courses, start=1):
#as start=1, index will be start from 1, default is 0
print(index,course)
#Making String from list
course_str = ', '.join(courses)
print(course_str)
#Making List from String
new_list= course_str.split(', ')
print(new_list)
#Set
cs_courses={'Maths', 'Physics', 'English', 'Sports','Chemistry' }
art_courses={'Maths', 'Art', 'English', 'Sports','Hindi' }
#Common in both the sets
print(cs_courses.intersection(art_courses))
#Element in set1 but not in set2
print(cs_courses.difference(art_courses))
#All Elements combined from both the set
print(cs_courses.union(art_courses))
#Creating empty list, tuple, set, dictionary
#Empty list
empty_list = []
empty_list = list()
#Empty Tuple
empty_tuple = ()
empty_tuple = tuple()
#Empty Set
empty_set = {} #this is wrong, this will create empty dictionary
empty_set = set()