D. Answer the following questions as you follow the instructions in the handout: XXX. 1. Write an expression that computes (i.e., evaluates to) the product of 8 and 3. 2. Write an expression that computes (i.e., evaluates to) the square root of 3. 3. Write here two expressions that cause error messages when they are evaluated. (Strive for examples that are different from those in the handout.) 4. Consider the statement x = 54. What is the type of the object to which the variable x refers? HINT: If you are not sure, you can check the type of a variable (e.g., x=54) by saying type(x). Note that if you use type(x) before entering x=54 in the console you will get an error because x does not yet have a value. ANS. int ANS. integer ANS. Integer 5. Consider the statement x = 54. What is the value of the object to which the variable x refers? ANS. 54 6. Consider the statement y = 3.713. What is the type of the object to which the variable y refers? ANS. float ANS. Float 7. Consider the statement y = 3.713. What is the value of the object to which the variable y refers? ANS. 3.713 8. Consider the statement z = 'my best friend'. What is the type of the object to which the variable z refers? ANS. str ANS. string ANS. String 9. Consider the statement z = 'my best friend'. What is the value of the object to which the variable z refers? ANS. my best friend ANS. "my best friend" ANS. 'my best friend' 10. Write a statement that assigns the variable my_friend the value 'Betty Bop'. ANS. my_friend = 'Betty Bop' ANS. my_friend= 'Betty Bop' ANS. my_friend ='Betty Bop' ANS. my_friend='Betty Bop' 11. Suppose that you run the following one-line program. What happens?

print('hello')

a. 'hello' appears on the screen b. hello appears on the screen~ c. "hello" appears on the screen d. an error occurs 12. Suppose that you run the following one-line program. What happens?

print(hello)

a. 'hello' appears on the screen b. hello appears on the screen c. "hello" appears on the screen d. an error occurs~ 13. What does the expression 3 * (4 + 1) evaluate to? (Figure this out by hand, then check your answer in the PyDev Console.) ANS. 15 14. What does the expression 3 * ('hi' + 'bye') evaluate to? (Figure this out by hand, then check your answer in the PyDev Console.) ANS. hibyehibyehibye ANS. 'hibyehibyehibye' 15. What is the value of y after the following set of statements executes? (Figure this out by hand, then check your answer in the PyDev Console.)

y = 5

y = y * 3

y = y + 1

ANS. 16 16. Assume that you have a variable x that has already been given a numeric value. Assume that you have put import math at the top of your program. Write a statement that sets the variable y to the sum of the sine of x and the cosine of x. ANS. y**=**math.sin(x)**+**math.cos(x) ANS. y**=**math.cos(x)**+**math.sin(x) 17. The same variable name can occur on both sides of the assignment operator (=) a. true~ b. false 18. int is a valid Python variable name. a. true~ b. false 19. Consider the following code snippet:
  x = 5
x = x + 3
x = x * 10
What is the value of x after the code snippet runs? ANS. 80 20. Consider the following code snippet:
  x = 5
x = x * 10
x = x + 3
What is the value of x after the code snippet runs? ANS. 53 21. Consider the following code snippet:
x = x * 10
x = x + 3
x = 5
What is the value of x after the code snippet runs? (Hint: This is a trick question. What will happen when the code snippet runs?) 22. Bobby decided to use int as a variable name and created the following code:

int = 2.5

print(int(int))

What happens when Bobby runs his code? a. An error occurs because int is no longer the name of a function but the name of a float.~ b. 2 is printed. c. 3 is printed. d. An error occurs because int cannot be used as a variable name. 23. It is okay to use a variable before we give it an initial value. a. true b. false~ D. Watch the video: Your First Programs, Part 4: Functions, doing the next set of questions while you do so. 24. What keyword marks the beginning of a function definition? ANS. def 25. What notation marks the body of the function (that is, how can we tell when one function ends and another starts)? a. Curly braces ({}) b. Colon (:) c. Indentation~ d. A new line or return 26. What is the name of the function that prints things (i.e., displays them on the console)? ANS. print ANS. print() D. Consider the following program for the next several questions:
. 27. Check all the line numbers for lines that call a function. a. Line 1 b. Line 2~ c. Line 3~ d. Line 6 e. Line 7~ f. Line 8~ g. Line 9~ h. Line 11~ i. Line 14 j. Line 15~ k. Line 17~ 28. Check all the line numbers for lines that begin a function definition. a. Line 1~ b. Line 2 c. Line 3 d. Line 6~ e. Line 7 f. Line 8 g. Line 9 h. Line 11 i. Line 14~ j. Line 15 k. Line 17 29. What does the program print when it runs? M. This is printed first:->go, robot, go! M. This is printed next:->go forward M. This is printed next:->go forward M. This is printed next:->stop, robot, stop! M. This is printed next:->go forward M. ->" " D. Watch the video: Calling Functions, doing the next set of questions while you do so. D. Consider the following function definition: 30. What is the name of the function? HINT: There should be no parenthesis ANS. f_to_c 31. How many parameters does the function have? ANS. one ANS. One ANS. 1 32. Why are functions powerful? a. They take parameters and allow code re-use. b. They do calculations and take parameters. c. They can have comments and do calculation. d. They improve organization and allow code re-use.~ 33. Choose the statement that correctly calls the f_to_c function. a. f_to_c 5 b. f_to_c c. def f_to_c(5) d. f_to_c(5)~ 34. What steps occur when

c = f_to_c(10.5)

is called (where the f_to_c function is as defined above)? M. Step 1 -> Actual values are sent to function parameters M. Step 2 -> Execution continues in the f_to_c function code M. Step 3 -> The calculated value for celsius is returned M. Step 4 -> The returned value is substituted where the function call occurred M. -> None is returned M. -> The value for celsius is printed D. Watch the video: Object Oriented Programming, doing the next set of questions while you do so. 35. Four computer languages developed in the 1950s dominated early computing. One of them is Lisp. What is the name of another? a. Procedural b. C c. ALGOL~ d. Assembly 36. This diagram is part of a: a. Poem called Beowulf b. Rocket ship c. Garbage can d. Flowchart~ 37. Procedural decomposition is: a. The process by which leftovers become fertilizer for gardens. b. What happens to mummies when they are left out in the open air. c. How great ideas become hollow ones. d. The process of breaking a problem into a sequence of subproblems, with each subproblem given a procedure to solve it, and then breaking those subproblems into sub-subproblems, with each sub-subproblem given a procedure to solve it, and so forth until the problem is reduced to procedures of manageable size.~ 38. The first object-oriented (OO) language was (in some historians' view) SIMULA, but the most influential of the early OO languages was: a. Smalltalk~ b. Bigmouth c. Farsight d. Giggles 39. Most of the widely-used languages developed since 1990 have been object oriented languages. a. true~ b. false 40. The procedural programming paradigm focuses on: a. Nouns b. Verbs~ c. Adjectives 41. The object-oriented programming paradigm focuses on: a. Nouns~ b. Verbs c. Adjectives 42. Today's software engineer typically uses both the procedural and object-oriented paradigms--there is a place for each. a. true~ b. false 43. Python supports both a procedural and an object-oriented notation a. true~ b. false D. Watch the video: Objects and Classes--Using Objects, doing the next set of questions while you do so. 44. What trick to we use in Eclipse to figure out what instance variables and methods an object has? a. CTRL + Space b. Dot trick~ c. CTRL + s d. F1 45. What trick do we use in Eclipse to figure out what arguments a constructor or method takes? a. CTRL + Space~ b. Dot trick c. CTRL + s d. F1 D. Watch the video: Coding to a Specification, doing the next set of questions while you do so. 46. The specification of a component has 3 most universal parts. What are those 3 parts? a. What goes into the component, what comes out of the component, and the side effects of the component.~ b. What goes into the component, what comes out of the component, and the purpose of the component. c. The purpose of the component, the amount of time it will take to run, and the number of parameters it needs. d. The name of the component, the parameters of the component, and what comes out of the component. 47. A specification states how the component works. a. true b. false~ 48. A specification states what the component does. a. true~ b. false