diff --git a/Python_Exercises.py b/Python_Exercises.py index d7e6135..d8db3c2 100644 --- a/Python_Exercises.py +++ b/Python_Exercises.py @@ -7,8 +7,10 @@ def power(a,b): # ** What is 7 to the power of 4?** - - return None + + return a**b +out= power(7,4) +print(out) @@ -20,7 +22,9 @@ def split_str(s): # # **into a list. ** - return None + return s.split() +output= split_str("Hi there Sam!") +print(output) def format(planet,diameter): @@ -35,7 +39,7 @@ def format(planet,diameter): # The diameter of Earth is 12742 kilometers. return None - +print("The diameter of {planet} is {diameter} kilometers." .format(planet='Earth', diameter='12742')) def indexing(lst): @@ -43,8 +47,11 @@ def indexing(lst): # ** Given this nested list, use indexing to grab the word "hello" ** #lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7] + return None +lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7] +lst[3][1][2] - return None + def dictionary(d): @@ -55,6 +62,8 @@ def dictionary(d): return None +d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello']}]}]} +d['k1'][3]['tricky'][3]['target'][3] def subjective(): @@ -63,7 +72,7 @@ def subjective(): # Tuple is _______ return None - +immutable