Set Functions & Operands
Apr 15 2017- POSTED BY projecth
Let’s pretend we have two sets. The first set will be the first ten positive whole numbers. The second will […]
Read MoreLet’s pretend we have two sets. The first set will be the first ten positive whole numbers. The second will […]
Read MoreSet Characteristics Unique A set is a collection of unique items that belong together for some reason. Example: A set […]
Read More# Dictionary >>> my_dict = {‘name’: ‘Kenneth’, ‘job’: ‘Teacher’} # Keys >>> my_dict[‘job’] ‘Teacher’ # Dictionaries as keys >>> name_dict […]
Read Morea_list.append( [4, 5] ) my_list = list( range(10) ) my_list + [10, 11, 12] our_list.extend( range(5,11) ) alpha.insert(1,’b’) new_list = […]
Read MoreRandom Choice >>> my_list = list(range(50)) >>> my_list [0,1,2,3,4, … , 49] >>> import random >>> random.choice(my_list) 15 >>> random.choice(my_list) […]
Read Moreenumerate( iterable ) Printing List via for-loop >>> my_alphabet_list = list(‘abcdefghijklmnopqrstuvwxyz’) >>> count = 0 >>> for letter in my_alphabet_list: … […]
Read MoreIntroduction Tuples are immutable lists. >>> my_tuple = (1,2,3) >>> my_tuple (1,2,3) Parentheses are not what makes a tuple a […]
Read Moreteachers_dict = {‘Jason Seifer’: [‘Ruby Foundations’, ‘Ruby on Rails Forms’, ‘Technology Foundations’], ‘Kenneth Love’: [‘Python Basics’, ‘Python Collections’]} def most_classes(teachers_dict): […]
Read MoreUnpacking Considering dictionaries, the format( ) function can be used several ways. Regular Way >>> my_string = “Hi! My name […]
Read MoreIntroduction >>> my_dict = {‘name’: ‘Kenneth’} >>> my_dict {‘name’: ‘Kenneth’} Key Order of keys can change over time. This is why […]
Read More[Start:Stop:Step] >>> my_list = list(range(20)) >>> my_list [0,1,2,3, … , 19] >>> my_list[::2] [0,2,4,6,8, … ,18] >>> my_list[2::2] [2,4,6,8, … […]
Read MoreItem Index >>> a_list = list(‘abzcd’) >>> a_list.index(‘z’) 2 Delete by index List Items Deletion >>> del a_list[2] >>> a_list [‘a’, […]
Read MoreCombining Lists append( list ) >>> a_list = [1, 2, 3] >>> a_list.append( [4, 5] ) >>> a_list [1, 2, […]
Read More