1. 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 2. Consider the statement x = 54. What is the value of the object to which the variable x refers? ANS. 54 3. Consider the statement y = 3.713. What is the type of the object to which the variable y refers? ANS. float ANS. Float 4. Consider the statement y = 3.713. What is the value of the object to which the variable y refers? ANS. 3.713 5. 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 6. 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' 7. 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' 8. 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 9. 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~ 10. What does the expression 3 * (4 + 1) evaluate to? ANS. 15 11. What does the expression 3 * ('hi' + 'bye') evaluate to? ANS. hibyehibyehibye ANS. 'hibyehibyehibye' 12. What is the value of y after the following set of statements executes?

y = 5

y = y * 3

y = y + 1

ANS. 16 13. 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) D. For the following questions perform experiments using a PyDev console in Eclipse (e.g., try using the same variable name on both sides of the assignment operator). 14. The same variable name can occur on both sides of the assignment operator (=) a. true~ b. false 15. int is a valid Python variable name. a. true~ b. false 16. 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. 17. It is okay to use a variable before we give it an initial value. a. true b. false~ 18. What keyword marks the beginning of a function definition? ANS. def 19. What notation marks the body of the function (that is, how can we tell when one function ends and another starts)? a. Indentation~ b. Curly braces ({}) c. Colon (:) d. A new line or return 20. What is the name of the function that prints things (i.e., displays them on the console)? ANS. print ANS. print() D. Watch the video: Calling Functions D. Consider the following function definition: 21. What is the name of the function? HINT: There should be no parenthesis ANS. f_to_c 22. How many parameters does the function have? ANS. one ANS. One ANS. 1 23. Choose 2 reasons why functions are powerful. a. They improve organization and allow code re-use.~ b. They take parameters and allow code re-use. c. They do calculations and take parameters. d. They can have comments and do calculation. 24. 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)~ 25. 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: Coding to a Specification. 26. 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. 27. A specification states how the component works. a. true b. false~ 28. A specification states what the component does. a. true~ b. false D. Do this reading: Counted Loops 29. Choose the correct lines to make a loop that prints 'funny' 40,000 times. M. Line 1->for k in range(40000): M. Line 2->    print('funny') M. ->for k in range(40001) M. ->for k in range(n) M. ->    return 'funny' M. ->    print 'funny' 30. Choose the correct lines to make a loop that prints the cubes of the numbers from 0 to m, inclusive (where m is some integer bigger than 35). For example, if m were 37, then this loop should print:

42875

46656

50653

These are 35 cubed, 36 cubed, and 37 cubed. M. Line 1->for i in range(m+1) M. ->for i in range(m) M. ->for i in range(0) M. Line 2->    print(i**3) M. ->    print(35**3) M. ->    print(m**3) D. Watch the video: Object Oriented Programming 31. 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 32. This diagram is part of a: a. Poem called Beowulf b. Rocket ship c. Garbage can d. Flowchart~ 33. 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.~ 34. 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 35. Most of the widely-used languages developed since 1990 have been object oriented languages. a. true~ b. false 36. The procedural programming paradigm focuses on: a. Nouns b. Verbs~ c. Adjectives 37. The object-oriented programming paradigm focuses on: a. Nouns~ b. Verbs c. Adjectives 38. Today's software engineer typically uses both the procedural and object-oriented paradigms--there is a place for each. a. true~ b. false 39. Python supports both a procedural and an object-oriented notation a. true~ b. false D. Watch the video: Objects and Classes--Using Objects 40. 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 41. 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