COSC 1436 Quiz 2

Ace your homework & exams now with Quizwiz!

What is the output of the following code. Assume that the user enters a 10 for the length and a 2 for the width: len = input("Enter a length of a rectangle: ") wid = input("Enter the width of a rectangle: ") len *= wid print(len) a. 20 b. 10 c. ERROR d. len

c. ERROR

Which Python statement assigns the sum of 1 and 2 to the variable answer a. 1+2 = answer b. 3 = answer c. answer = 1+2 d. answer = 3

c. answer = 1+2

Suppose that you want to read a float value into x, which of the following statement correctly reads the input and stores the float value into x. assume that input value is 32.6: a. x = float(get('Enter a value: ')) b. x = input(float('Enter a value:')) c. x = float(input('Enter a value:')) d. x = input('Enter a value: ')

c. x = float(input('Enter a value:'))

________ describes algorithms using natural language mixed with code. a. a python program b. a flowchart diagram c. a python statement d. pseudocode

d. pseudocode

What is the output of the following command, given that value1 = 2.0 and value2 = 12.2 print(round(value1 + value2)) a. 24.0 b. value1 * value2 c. 2.0 * 12 d. value1 * value2 e. 24

e. 24

(Matching) Assume the following: val = 99 val += 1 Match the code with its output: print('The value is', 'val') print('The value is', val)' print("The value is:", 'val')

print('The value is', 'val') == The value is val print('The value is', val) == The value is 100 print("The value is:", 'val') == The value is: val

(Matching) After the execution of the following statements, the variable results will hold/ store what kind of data type? result = 123.456 result = int(123.456) result = "123.456" result = '123' result = 123 result = 123.0

result = 123.456 => float result = int(123.456)=> int result = "123.456" => string result = '123' => int result = 123 => result = 123.0 => float

(Matching) Match the expression to its result: 9//2 9/2 9%2 9**2

9//2 == 4 9/2 == 4.5 9%2 == 1 9**2 == 81

After the execution of the following statement, the variable price will reference the value _______. price = int(68.549) a. 68 b. 68.55 c. 68.6 d. 69

a. 68

Match the following terms with definitions: System Analysis: System Design: IPO:

System Analysis: stage to identify the system input and output System Design: system when programmers develop a process for obtaining the output from the input IPO: essence of system analysis and design

Algorithms __________. a. describes how problems are solved by listing the actions that need to be taken and the order of their execution. b. All of the answer choices are incorrect c. can help the programmer plan a program before writing in a programming language d. can be described in natural languages or in pseudocode

b. All of the answer choices are incorrect

(T or F) The following is a valid statement: value = $3,450 a. True b. False

b. False

The Software Development Life Cycle (SDLC) is a multistage process that includes requirements spec., system analysis, system design, implementation, testing, deployment, and maintenance a. True b. False

a. True

Which of the following are valid camel case identifier naming style (Choose all that apply)? a. dollarAmt b. amtDollar c. dollarAmount d. Dollar_Amount e. dollar$Amount f. amountDollar g. dollarAmt$ h. dollar_amount

a. dollarAmt b. amtDollar c. dollarAmount f. amountDollar

Check all the illegal variable names: a. sixth#place b. 1stplace c. SecondPlace2 d. third_place e. FIFTH_PLACE f. fourthPlace

a. sixth#place b. 1stplace c. SecondPlace2

import is an illegal identifier because it is a keyword or reserved word a. true b. false

a. true

In the expression 12 + 7: a/ The 12 and 7 are the: b/ The + is the: 1/ operand(s) 2/operator(s)

a/ The 12 and 7 are the: 1/ operand(s) b/ The + is the: 2/operator(s)

What is the output of the following statement: print(2 + 3 * 2 + 7// 2 - 10 ) a. 1.5 b. 1 c. 3 d. 3.5

b. 1

Which of the following statements will cause an error? a. x = 17 b. 17 = x

b. 17 = x

What will be displayed by the following code? a, b = 5, 6 a, b = b, a print(a, b) a. 6 6 b. 6 5 c. 5 5 d. 5 6

b. 6 5


Related study sets

Types of Characteristic of Fixed Income unit 13

View Set

Physics: Energy, Momentum, and Work

View Set