Set Functions & Operands

Let’s pretend we have two sets. The first set will be the first ten positive whole numbers. The second will […]

Read More

Set Basics

Set Characteristics Unique A set is a collection of unique items that belong together for some reason. Example: A set […]

Read More

APPENDIX: Dicts & Tuples

# Dictionary >>> my_dict = {‘name’: ‘Kenneth’, ‘job’: ‘Teacher’} # Keys >>> my_dict[‘job’] ‘Teacher’ # Dictionaries as keys >>> name_dict […]

Read More
Comments Off on APPENDIX: Dicts & Tuples

APPENDIX: Lists

a_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 More
Comments Off on APPENDIX: Lists

Dungeon Game

Random 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 More
Comments Off on Dungeon Game

Tuple Iteration

enumerate( iterable ) Printing List via for-loop >>> my_alphabet_list = list(‘abcdefghijklmnopqrstuvwxyz’) >>> count = 0 >>> for letter in my_alphabet_list: …   […]

Read More
Comments Off on Tuple Iteration

Tuples Basics

Introduction Tuples are immutable lists. >>> my_tuple = (1,2,3) >>> my_tuple (1,2,3) Parentheses are not what makes a tuple a […]

Read More
Comments Off on Tuples Basics

Teachers Stats

teachers_dict = {‘Jason Seifer’: [‘Ruby Foundations’, ‘Ruby on Rails Forms’, ‘Technology Foundations’], ‘Kenneth Love’: [‘Python Basics’, ‘Python Collections’]} def most_classes(teachers_dict): […]

Read More
Comments Off on Teachers Stats

Dictionary Unpacking & Iteration

Unpacking Considering dictionaries, the format( ) function can be used several ways. Regular Way >>> my_string = “Hi! My name […]

Read More
Comments Off on Dictionary Unpacking & Iteration

Dictionary Basics

Introduction >>> my_dict = {‘name’: ‘Kenneth’} >>> my_dict {‘name’: ‘Kenneth’} Key Order of keys can change over time. This is why […]

Read More
Comments Off on Dictionary Basics

Slice with Steps

[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 More
Comments Off on Slice with Steps

Slices

Slicing Strings >>> my_string = “Hello there” >>> my_string[1:5] ‘ello’ >>> my_string[2] ‘l’ Slicing Lists >>> my_list = list(range(1,6)) >>> my_list […]

Read More
Comments Off on Slices

Pop

pop( index ) >>> names = [“Bashar”, “Ahmad”, “Mustafa”] >>> name_1 = names.pop() >>> name_1 ‘Mustafa’ >>> names [“Bashar”, “Ahmad”] […]

Read More
Comments Off on Pop

Removing List Items

Item Index >>> a_list = list(‘abzcd’) >>> a_list.index(‘z’) 2 Delete by index List Items Deletion >>> del a_list[2] >>> a_list [‘a’, […]

Read More
Comments Off on Removing List Items

Lists Redux

Combining Lists append( list ) >>> a_list = [1, 2, 3] >>> a_list.append( [4, 5] ) >>> a_list [1, 2, […]

Read More
Comments Off on Lists Redux