# lists - mutable containers of items accessible by index
courses = ["Scientific Computing", "Imperative Problem Solving", "Data Structures", "Operating Systems"]
grades = [90, 80, 75, 100, 88, 92, 74, 90]
randomStuff = ["word", 1, 'b', 3.14]

# iterating through lists by item
for item in courses:
    print("item is: ", item)

# iterating through lists by index position
for index in range(len(courses)):
    item = courses[index]
    print("item at index ", index, " is: " , item)

# other list functions
length = len(courses) # number of items in the list
newList1 = courses*3 # create a new list containing all items repeated 3 times
newList2 = courses + ["Algorithms", "Theory of Computing"] # concatenation -- put two lists together
occurrences = grades.count(90) # returns the number of times an item occurred in the list

# index
firstItem = courses[0] # access element at index 0
lastItem = courses[-1] # access element at last index
courses[0] = "CS 100" # change the element at index 0
itemIdx = courses.index("Imperative Problem Solving") # gives the index of where the item is located


# other mutations to list
courses.append("Programming Languages") # add to the end of the list
courses.insert(3, "Software Engineering") # add to index 3
lastItem = grades.pop() # remove and return last item of the list
firstItem = grades.pop(0) # remove item at index 0 and return it
grades.sort() # modify the given list so all items are in ascending order
grades.reverse() # modify the given list so all items are in order reverse to what they were
courses.remove("Data Structures")

# slice operator
subList1 = courses[:3] # list containing all items from the beginning up to but not including index 3
subList2 = courses[3:] # list containing all items from index 3 all the way to the end
subList3 = courses[2:4] # list containing all items from index 2 up to but not including 4
fullCopy = courses[:] # a copy of the list

# membership/containment operator
bool1 = "Data" in courses # return whether the entire item "Data" is in the list
bool2 = "Data" not in courses # return whether the entire item "Data" is NOT in the list

# other list functions (assuming list is of numbers)
mySum = sum(grades)
myMax = max(grades)
myMin = min(grades)

# getting a list from a string
myString = "Python is fun"
myList = myString.split(" ")