Changes

Jump to: navigation, search

OPS435 Python Lab 4

2 bytes added, 13:04, 19 May 2017
PART 4 - List Comprehension
== PART 2 - Set ==
:Sets are another very similar structure to lists, they can also be modified and changed, unlike the tuple. But sets have two unique characteristics, they are unordered, and they cannot have duplicate values. The unordered part provides a added performance from hashing the values, but also means we cannot pull out a specific value at a spefici position. Any duplicate entries will immediately be deleted. Sets however are great tools for doing comparisons, finding differences in multiple sets, or finding similarities. The best part about sets are, they are fast!
Lets create a couple sets to work with.
== PART 4 - List Comprehension ==
:We've already covered lists to a degree. Lets move into more advanced functions to use and generate lists. This is a very common practice in Python, understanding how to generate, manipulate, and apply functions to items inside a list can be incredibly useful. List comprehension is a way to build new lists from existing list.
Lets start with creating a list and applying some function to each item in the list. The below will print out the square of each item.
13,420
edits

Navigation menu