CS Exam 1 - Chapter 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following functions cause an error? A. int("034") B. eval("034") C. int("3.4") D. eval("3.4")

BC

To add a value 1 to variable x, you write A. 1 + x = x B. x += 1 C. x := 1 D. x = x + 1 E. x = 1 + x

BDE

Which of the following functions return 4. A. int(3.4) B. int(3.9) C. round(3.4) D. round(3.9)

D

To add number to sum, you write (Note: Python is case-sensitive) A. number += sum B. number = sum + number C. sum = Number + sum D. sum += number E. sum = sum + number

DE

Which of the following statements are the same? (A) x -= x + 4 (B) x = x + 4 - x (C) x = x - (x + 4)

(A) and (C) are the same

25 % 1 is _____

0

Suppose x is 1. What is x after x -= 1?

0

Which of the following expressions will yield 0.5? 1 / 2 1.0 / 2 1 // 2 1.0 // 2 1 / 2.0

1 / 2 1.0 / 2 1 / 2.0

To following code reads two number. Which of the following is the correct input for the code? x, y = eval(input("Enter two numbers: "))

1, 2

What is the result of 45 // 4?

11

What is the result of 45 / 4?

11.25

2 * 3 ** 2 evaluates to __________.

18

What is x after the following statements? x = 1 x *= x + 1

2

What will be displayed by the following code? x, y = 1, 2 x, y = y, x print(x, y)

2 1

If you enter 1 2 3 in three separate lines, when you run this program, what will be displayed? print("Enter three numbers: ") number1 = eval(input()) number2 = eval(input()) number3 = eval(input()) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average)

2.0

If you enter 1, 2, 3, in one line, when you run this program, what will be displayed? number1, number2, number3 = eval(input("Enter three numbers: ")) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average)

2.0

Suppose x is 1. What is x after x += 2?

3

What is x after the following statements? x = 1 y = 2 x *= y + 1

3

What will be displayed by the following code? x = 1 x = 2 * x + 1 print(x)

3

What will be displayed by the following code? x = 1 x = x + 2.5 print(x)

3.5

Which of the following expression results in a value 1? 2 % 1 15 % 4 25 % 5 37 % 6

37 % 6

24 % 5 is _____

4

What is x after the following statements? x = 2 y = 1 x *= y + 1

4

What is the result of evaluating 2 + 2 ** 3 / 2?

6.0

What is the result of eval("1 + 3 * 2")?

7

What is the value of i printed? j = i = 1 i += j + j * 5 print("What is i?", i)

7

2 ** 3 evaluates to __________.

8

2 ** 3.0 evaluates to __________.

8.0

What function do you use to read a string?

input("Enter a string")

Which of the following is a valid identifier? $343 mile 9X 8+9 max_radius

mile max_radius

Which of the following is a valid identifier? import mile1 MILE (red) "red"

mile1 MILE

In the expression 45 / 4, the values on the left and right of the / symbol are called ____.

operands

The time.time() returns ________________ .

the current time in milliseconds since midnight, January 1, 1970 GMT (the Unix time).

An identifier can contain digits, but cannot start with a digit True or False

true

An identifier cannot be a keyword True or False

true

What is y displayed in the following code? x = 1 y = x = x + 1 print("y is", y)

y is 2 because x + 1 is assigned to x and then x is assigned to y.

_______ is the code in natural language mixed with some program code.

Pseudocode

If you enter 1 2 3 in one line, when you run this program, what will happen? print("Enter three numbers: ") number1 = eval(input()) number2 = eval(input()) number3 = eval(input()) # Compute average average = (number1 + number2 + number3) / 3 # Display result print(average)

The program will have a runtime error on the input.

You can place the line continuation symbol __ at the end of a line to tell the interpreter that the statement is continued on the next line.

\

Which of the following is equivalent to 0.025? A. 0.25E-1 B. 2.5e-2 C. 0.0025E1 D. 0.00025E2 E. 0.0025E+1

all of the above!

If a number is too large to be stored in memory, it _____________.

causes overflow


Kaugnay na mga set ng pag-aaral

American Red Cross BLS Training LESSON 2

View Set

Pharmacology Exam 3 Practice Questions

View Set

UTC PEDS EXAM TWO PRACTICE QUESTIONS

View Set

Physics Lab 1 Test - Quizzes From The Year

View Set