Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Iss07 #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions LM-1201/00-prep-02-overview-of-rest-apis/spark-room-easy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
spark_header = {'Authorization': accessToken_hdr}
uri = 'https://api.ciscospark.com/v1/rooms'
resp = requests.get(uri, headers=spark_header)
print("Spark Rooms you belong to: ")
print("Spark Rooms you belong to: ")
print(resp.text)

print()
print("Spark Rooms in easier to read format - pretty format:")
print (json.dumps(resp.json(), indent=4, separators=(',', ': ')))

2 changes: 1 addition & 1 deletion LM-1201/02-python-primer/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
print("My name is " + name + ". I'm " + str(feet) + " feet " + str(inches) + " inches tall.")

myStr = "My name is " + name + ". I'm " + str(feet) + " feet " + str(inches) + " inches tall."
print(myStr)
print(myStr)
2 changes: 1 addition & 1 deletion LM-1201/02-python-primer/concat_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
myStr = myVarBlue + " violets can grow up to " + str(inches) + " inches!"
print(myStr)

print("The " + myVarBlue + " sky turned " + myVarRed + "!")
print("The " + myVarBlue + " sky turned " + myVarRed + "!")
2 changes: 1 addition & 1 deletion LM-1201/02-python-primer/hello.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

print ("Hello World!")

print ("How are you?")
print ("How are you?")
8 changes: 4 additions & 4 deletions LM-1201/02-python-primer/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
num = 1

if num < 1:
print ("I'm less than 1!")
print ("I'm less than 1!")
elif num ==1:
print("I'm equal to 1.")
print("I'm equal to 1.")
else:
print ("Goodbye Cruel World!")
print ("Goodbye Cruel World!")

print("I always get printed!")

Expand All @@ -17,4 +17,4 @@

print("the val is " + str(val))

new_val="the value is" + str(val)
new_val="the value is" + str(val)
6 changes: 3 additions & 3 deletions LM-1201/02-python-primer/myworldsol.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
num = 1

if num < 1:
print ("I'm less than 1!")
print ("I'm less than 1!")
elif num > 1:
print ("I'm bigger than 1!")
print ("I'm bigger than 1!")
else:
print ("I'm the default statement!")
print ("I'm the default statement!")
21 changes: 10 additions & 11 deletions LM-1201/03-python-primer2/call_functions.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
print ("I'm not a function")

def my_function():
print("Hey I'm a function!")
print("Hey I'm a function!")


def brett(val):
for i in range(val):
print("I'm a function with args!")
for i in range(val):
print("I'm a function with args!")

def new_func(data):
data2= "my data is " + str(data)
return (data2)
data2= "my data is " + str(data)
return (data2)

def calc(num,num2):
var=num * num2
print(var)
var=num * num2
print(var)

my_function()
brett(5)
my_data=new_func("happy")
print(my_data)
calc(5,10)

20 changes: 10 additions & 10 deletions LM-1201/03-python-primer2/call_functions_sol.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
print ("I'm not a function")

def my_function():
print("Hey I'm a function!")
print("Hey I'm a function!")


def brett(val):
for i in range(val):
print("I'm a function with args!")
for i in range(val):
print("I'm a function with args!")

def my_funct():
print("I'm a new function!")
print("I'm a new function!")

def my_funct2(name):
print(name + " wrote this function!")
print(name + " wrote this function!")


my_function()
brett(5)
my_funct()
my_funct2("Brett")
my_funct2("Brett")
2 changes: 1 addition & 1 deletion LM-1201/03-python-primer2/my_data_types_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@


my_dict={"red":1,"green":2}
print(my_dict["green"])
print(my_dict["green"])
6 changes: 3 additions & 3 deletions LM-1201/03-python-primer2/nested_datatypes_loops.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
food={"vegetables":["carrots","kale","cucumber","tomato"],"desserts":["cake","ice cream", "donut"]}
for hungry in food["vegetables"]:
print("My favorite vegetable is " + hungry)
print("My favorite vegetable is " + hungry)

cars={"sports":{"Volkswagon":"Porsche","Dodge":"Viper","Chevy":"Corvette"},"classic":{"Mercedes-Benz":"300SL","Toyota":"2000GT","Lincoln":"Continental"}}
for auto in cars["sports"]:
print("My favorite sports car is a " + cars["sports"][auto])
print("My favorite sports car is a " + cars["sports"][auto])

dessert={"iceCream":["Rocky Road","strawberry","Pistachio Cashew","Pecan Praline"]}


Expand Down
12 changes: 6 additions & 6 deletions LM-1201/03-python-primer2/nested_datatypes_loops_sol.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
food={"vegetables":["carrots","kale","cucumber","tomato"],"desserts":["cake","ice cream", "donut"]}
for hungry in food["vegetables"]:
print("My favorite vegetable is " + hungry)
print("My favorite vegetable is " + hungry)
for hungry in food["desserts"]:
print("My favorite dessert is " + hungry)
print("My favorite dessert is " + hungry)

cars={"sports":{"Volkswagon":"Porsche","Dodge":"Viper","Chevy":"Corvette"},"classic":{"Mercedes-Benz":"300SL","Toyota":"2000GT","Lincoln":"Continental"}}
for auto in cars["sports"]:
print("My favorite sports car is " + cars["sports"][auto])
print("My favorite sports car is " + cars["sports"][auto])
for auto in cars["classic"]:
print("My favorite classic car is " + cars["classic"][auto])
print("My favorite classic car is " + cars["classic"][auto])

dessert={"iceCream":["Rocky Road","strawberry","Pistachio Cashew","Pecan Praline"]}
for yummy in dessert["iceCream"]:
print("My favorite dessert is " + yummy)
print("My favorite dessert is " + yummy)

soup={"soup":{"tomato":"healthy","onion":"bleh!","vegetable":"good for you"}}
for tastey in soup["soup"]:
print("This soup is " + soup["soup"][tastey])
print("This soup is " + soup["soup"][tastey])
12 changes: 6 additions & 6 deletions LM-1201/03-python-primer2/nested_datatypes_loops_sol2.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
food={"vegetables":["carrots","kale","cucumber","tomato"],"desserts":["cake","ice cream", "donut"]}
for hungry in food["vegetables"]:
print("My favorite vegetable is " + hungry)
print("My favorite vegetable is " + hungry)
for hungry in food["desserts"]:
print("My favorite dessert is " + hungry)
print("My favorite dessert is " + hungry)

cars={"sports":{"Volkswagon":"Porsche","Dodge":"Viper","Chevy":"Corvette"},"classic":{"Mercedes-Benz":"300SL","Toyota":"2000GT","Lincoln":"Continental"}}
for auto in cars["sports"]:
print("My favorite sports car make and model is the " + auto + " " + cars["sports"][auto])
print("My favorite sports car make and model is the " + auto + " " + cars["sports"][auto])
for auto in cars["classic"]:
print("My favorite classic car make and model is the " + auto + " " + cars["classic"][auto])
print("My favorite classic car make and model is the " + auto + " " + cars["classic"][auto])

dessert={"iceCream":["Rocky Road","strawberry","Pistachio Cashew","Pecan Praline"]}
for yummy in dessert["iceCream"]:
print("My favorite dessert is " + yummy)
print("My favorite dessert is " + yummy)

soup={"soup":{"tomato":"healthy","onion":"bleh!","vegetable":"good for you"}}
for tastey in soup["soup"]:
print("This " + tastey + " soup is " + soup["soup"][tastey])
print("This " + tastey + " soup is " + soup["soup"][tastey])
14 changes: 7 additions & 7 deletions LM-1201/04-python-json/json_parse_1.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
var={"car":"volvo", "fruit":"apple"}
print(var["fruit"])
for f in var:
print("key: " + f + " value: " + var[f])
for f in var:
print("key: " + f + " value: " + var[f])
print()
print()

var1={"donut":["chocolate","glazed","sprinkled"]}
print(var1["donut"][0])
print("My favorite donut flavors are:", end= " ")
for f in var1["donut"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

#Using the examples above write code to print one value of each JSON structure and a loop to print all values.
#Using the examples above write code to print one value of each JSON structure and a loop to print all values.
var={"vegetable":"carrot", "fruit":"apple","animal":"cat","day":"Friday"}


var1={"animal":["dog","cat","fish","tiger","camel"]}


myvar={"dessert":"ice cream", "exercise":"push ups","eyes":"blue","gender":"male"}


myvar1={"dessert":["cake","candy","ice cream","pudding","cookies"]}

myvar1={"dessert":["cake","candy","ice cream","pudding","cookies"]}
22 changes: 11 additions & 11 deletions LM-1201/04-python-json/json_parse_1_sol.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
var={"car":"volvo", "fruit":"apple"}
print(var["fruit"])
for f in var:
print("key: " + f + " value: " + var[f])
for f in var:
print("key: " + f + " value: " + var[f])
print()
print()

var1={"donut":["chocolate","glazed","sprinkled"]}
print(var1["donut"][0])
print("My favorite donut flavors are:", end= " ")
for f in var1["donut"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

#Using the examples above write code to print one value of each JSON structure and a loop to print all values below.
#Using the examples above write code to print one value of each JSON structure and a loop to print all values below.
var={"vegetable":"carrot", "fruit":"apple","animal":"cat","day":"Friday"}
print(var["vegetable"])
for f in var:
print("key: " + f + " value: " + var[f])
for f in var:
print("key: " + f + " value: " + var[f])
print()
print()

var1={"animal":["dog","cat","fish","tiger","camel"]}
print(var1["animal"][0])
print("My favorite animals are:", end= " ")
for f in var1["animal"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

myvar={"dessert":"ice cream", "exercise":"push ups","eyes":"blue","gender":"male"}
print(myvar["exercise"])
for f in myvar:
print("key: " + f + " value: " + myvar[f])
for f in myvar:
print("key: " + f + " value: " + myvar[f])
print()
print()
print()

myvar1={"dessert":["cake","candy","ice cream","pudding","cookies"]}
print(myvar1["dessert"][0])
print("My favorite desserts are:", end= " ")
for f in myvar1["dessert"]:
print(f, end=" ")
print(f, end=" ")
13 changes: 6 additions & 7 deletions LM-1201/04-python-json/json_parse_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
print(var["donut"]["flavors"][0])
print("My favorite donut flavors are:", end=" ")
for f in var["donut"]["flavors"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

var1={"type":"donut","flavors":{"flavor":[{"type":"chocolate","id":1001}, {"type":"glazed","id":1002},{"type":"sprinkled","id":1003}]}}
print("Id: " + str(var1["flavors"]["flavor"][0]["id"]) + " type: " + var1["flavors"]["flavor"][0]["type"])
for f in var1["flavors"]["flavor"]:
print("Id: " + str(f["id"]) + " type: " + f["type"])
print("Id: " + str(f["id"]) + " type: " + f["type"])
print()
print()
#Using the examples above write code to print one value of each JSON structure and a loop to print all values.


#Using the examples above write code to print one value of each JSON structure and a loop to print all values.
myvar={"exercise":{"high impact":["running","jumping","jump rope","running down stairs","skiing"]}}


myvar={"foods":{"healthy":["yogurt","nuts","vegetables","fruits","beans"]}}


myvar1={"author":"Stephen King","famous works":{"novels":[{"title":"The Shining","id":1001}, {"title":"Carrie","id":1002},{"title":"It","id":1003},{"title":"Misery","id":1004},{"title":"Night Shift","id":1005}]}}


myvar1={"type":"car","cars":{"sports":[{"make":"Chevrolet", "model":"Corvette", "id":1001},{"make":"Chevrolet", "model":"Camaro", "id":1002},{"make":"Ford", "model":"Mustang", "id":1003},{"make":"Dodge", "model":"Viper", "id":1004},{"make":"Porsche", "model":"911", "id":1005}]}}

19 changes: 9 additions & 10 deletions LM-1201/04-python-json/json_parse_2_sol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,43 @@
print(var["donut"]["flavors"][0])
print("My favorite donut flavors are:", end=" ")
for f in var["donut"]["flavors"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

var1={"type":"donut","flavors":{"flavor":[{"type":"chocolate","id":1001}, {"type":"glazed","id":1002},{"type":"sprinkled","id":1003}]}}
print("Id: " + str(var1["flavors"]["flavor"][0]["id"]) + " type: " + var1["flavors"]["flavor"][0]["type"])
for f in var1["flavors"]["flavor"]:
print("Id: " + str(f["id"]) + " type: " + f["type"])
print("Id: " + str(f["id"]) + " type: " + f["type"])
print()
print()
#Using the examples above write code to print one value of each JSON structure and a loop to print all values.

#Using the examples above write code to print one value of each JSON structure and a loop to print all values.
myvar={"exercise":{"high impact":["running","jumping","jump rope","running down stairs","skiing"]}}
print(myvar["exercise"]["high impact"][0])
print("My favorite high impact exercises are:", end=" ")
for f in myvar["exercise"]["high impact"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

myvar={"foods":{"healthy":["yogurt","nuts","vegetables","fruits","beans"]}}
print(myvar["foods"]["healthy"][0])
print("My favorite healthy foods are:", end=" ")
for f in myvar["foods"]["healthy"]:
print(f, end=" ")
print(f, end=" ")
print()
print()

myvar1={"author":"Stephen King","famous works":{"novels":[{"title":"The Shining","id":1001}, {"title":"Carrie","id":1002},{"title":"It","id":1003},{"title":"Misery","id":1004},{"title":"Night Shift","id":1005}]}}
print("id: " + str(myvar1["famous works"]["novels"][0]["id"]) + " novel: " + myvar1["famous works"]["novels"][0]["title"])
for f in myvar1["famous works"]["novels"]:
print("Id: " + str(f["id"]) + " novel: " + f["title"])
print("Id: " + str(f["id"]) + " novel: " + f["title"])
print()
print()


myvar1={"type":"car","cars":{"sports":[{"make":"Chevrolet", "model":"Corvette", "id":1001},{"make":"Chevrolet", "model":"Camaro", "id":1002},{"make":"Ford", "model":"Mustang", "id":1003},{"make":"Dodge", "model":"Viper", "id":1004},{"make":"Porsche", "model":"911", "id":1005}]}}
print("id: " + str(myvar1["cars"]["sports"][0]["id"]) + " make: " + myvar1["cars"]["sports"][0]["make"] + " model: " + myvar1["cars"]["sports"][0]["model"])
for f in myvar1["cars"]["sports"]:
print("id: " + str(f["id"]) + " make: " + f["make"] + " model: " + f["model"])

print("id: " + str(f["id"]) + " make: " + f["make"] + " model: " + f["model"])
Loading