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

APPENDIX

print(“Bashar”) dir(str) help(print) help(str.rjust) “Bashar”.rjust(35) input(“What is your name?”) if name == “Bashar”: print(name + ” is a lumberjack!”) { […]

Read More
Comments Off on APPENDIX

Guess The Number!

My Solution Guess a number from 1 to 10 game. import random def init_game(): print(“Guess a number between 1 and 10. […]

Read More
Comments Off on Guess The Number!

Putting the “Fun” Back in “Function”

Introduction To Functions Definition def say_hello( ): print(“Hello!”) Arguments def add_to_two(num): print(num+2) >>> add_to_two(2) 4 Return def square(num): return num*num […]

Read More
Comments Off on Putting the “Fun” Back in “Function”

Shopping List

Lists Lists my_list = [ 1, 2.5, ‘a’ ] >>> list(‘a’) # Function creates a list of characters from the […]

Read More
Comments Off on Shopping List

Things That Count

Numeric Variables a = 1, b = 2 c = a + b >>> print(c) 3  int( variable ) [string_multiply]: input_string […]

Read More
Comments Off on Things That Count

Ins & Outs

Input/Output Output: print(“Bashar”) Input:    input(“What is your name?”) >>> name = input(“What is your name? “) What is your name? Bashar >>> print(name) Bashar String Concatination [lumberjack.py]: name = input(“What’s your name? “) […]

Read More

Say Hello to Python

At the end of this course, we’re going to build a Guess the Number game. There are two ways to […]

Read More

Setup A Python Environment

Installing Python from http://www.python.org To automatically be able to access python through the command prompt, Make sure to install Add python.exe […]

Read More
Comments Off on Setup A Python Environment

XHTML

Read More