# Commits

committed 2c8e932

Update worksheet 9

# Worksheets/Worksheet 09.py

` `
` # Block 1`
` for i in range(5):`
`-    print (i+1)`
`+    print(i + 1)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 2`
` for i in range(5):`
`-    print (i)`
`-    i=i+1`
`+    print(i)`
`+    i = i + 1`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 3`
` x=0`
` for i in range(5):`
`-    x+=1`
`-print (x)`
`+    x += 1`
`+print(x)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 4`
` x=0`
` for i in range(5):`
`     for j in range(5):`
`-        x+=1`
`+        x += 1`
` print (x)        `
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 5`
` for i in range(5):`
`     for j in range(5):`
`-        print (i,j)`
`+        print(i, j)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 6`
` for i in range(5):`
`     for j in range(5):`
`-        print ("*",end="")`
`-        print ()`
`+        print("*", end="")`
`+        print()`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 7`
` for i in range(5):`
`     for j in range(5):`
`-        print ("*",end="")`
`+        print("*", end="")`
`     print ()`
`  `
`-Prediction:`
`+# Prediction:`
`  `
`-Actual:`
`+# Actual:`
`  `
` # Block 8`
` for i in range(5):`
`     for j in range(5):`
`         print ("*",end="")`
` print ()`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 9`
`-# What is the mistake here?`
` array=[5,8,10,4,5]`
` i=0`
` for i in array:`
`     i = i + array[i]`
` print(i)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
`+# What is likely the mistake made?`
`+ `
` # Block 10`
` for i in range(5):`
`-    x=0`
`+    x = 0`
`     for j in range(5):`
`-        x+=1`
`+        x += 1`
` print (x)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 11`
` import random`
`-play_again="y"`
`-while play_again=="y":`
`+play_again = "y"`
`+while play_again == "y":`
`     for i in range(5):`
`         print (random.randrange(2),end="")`
`     print ()`
`     play_again=input("Play again? ")`
` print ("Bye!")`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 12`
` def f1(x):`
`     print (x)`
` y=3`
` f1(y)`
`  `
`-Prediction:`
`+# Prediction:`
`  `
`-Actual:`
`+# Actual:`
`  `
` # Block 13`
` def f2(x):`
`-    x=x+1`
`+    x = x + 1`
`     print (x)`
`-y=3`
`+y = 3`
` f2(y)`
` print (y)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 14`
` def f3(x):`
`-    x=x+1`
`+    x = x + 1`
`     print (x)`
`-x=3`
`+x = 3`
` f3(x)`
` print (x)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 15`
` def f4(x):`
`     z=x+1`
` x=3`
` f4(x)`
` print (z)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 16`
` def foo(x):`
`     x=x+1`
` print ("x=",x)`
` foo(x)`
` print ("x=",x)`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` # Block 17`
` def f():`
`     print ("f start")`
`      `
` f()`
`  `
`-Prediction:`
`+# Prediction:`
`  `
`-Actual:`
`+# Actual:`
`  `
` # Block 18`
` def foo():`
` foo()`
` print ("x=",x)`
` Block 19`
`-(This demonstrates a new concept that won�t be fully explained until Chapter 13.)`
`+#(This demonstrates a new concept that won�t be fully explained until Chapter 13.)`
` def a(x):`
`     print ("a",x)`
`     x=x+1`
` print ("main",y[1])`
` c(y)`
` print ("main",y[1])`
`+ `
`+# Prediction:`
`+ `
`+# Actual:`
`+ `
` `
`- `
`-Prediction:`
`- `
`-Actual: `
`- `
`-Correct the following code:`
`-(Don�t let it print out the word �None�)`
`+# ---- Correct the following code:`
`+# (Don�t let it print out the word "None")`
` def sum(a,b,c):`
`     print (a+b+c)`
`  `
` def increase(x):`
`     return x+1`
`  `
`-x=10`
`+x = 10`
` print ("X is",x," I will now increase x." )`
` increase(x)`
` print ("X is now",x)`
`-Correct the following code:`
`+`
`+# Correct the following code:`
` def print_hello:`
`     print ("Hello")`
`  `
`  `
` list=[45,2,10,-5,100]`
` print (sum_list(list))`
`-Correct the following code: (This almost reverses the string. What is wrong?)`
`+`
`+# Correct the following code: (This almost reverses the string. What is wrong?)`
` def reverse(text):`
`     result=""`
`     text_length=len(text)`
` text="Programming is the coolest thing ever."`
` print (reverse(text))`
`  `
`-Correct the following code:`
`+# Correct the following code:`
` def get_user_choice():`
`     while True:`
`         command=input("Command: ")`
` # 10. Write code to call the function above and print the result.`
` `
` # 11. Write a function that takes three numbers as parameters, and returns the centrifugal force. The formula for centrifugal force is: `
`-F=mr?2 `
`-F is force, r is radius, ? is angular velocity, m is mass.`
`+F=m(v**2)/r `
`+F is force, r is radius, v is angular velocity, m is mass.`
` `
` # 12. Write code to call the function above and print the result.`
` `
`-# 13. Write a function that takes a list of numbers as a parameter, and prints out each number individually using a �for� loop.`
`+# 13. Write a function that takes a list of numbers as a parameter, and prints out each number individually using a "for" loop.`
` `
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.