INSY 3300 Exam Review
The process known as the __________ cycle is used by the CPU to execute instructions in a program. a. decode-fetch-execute b. decode-execute-fetch c. fetch-decode-execute d. fetch-execute-decode
C
Which of the following functions is a built-in function in python? a) seed() b) sqrt() c) factorial() d) print()
D
def loopTest(): n=0 while n < 10: n +=1 if n ==5: break print(n) loopTest()
1 2 3 4
def loopTest(): n=0 while n < 10: n +=1 if n ==5: continue print(n) loopTest()
1 2 3 4 6 7 8 9 10
range can be used to produce a variety of sequences, please list the output of the following range() functions 1. range(1, 10, 2) → 2. range(10, 0, -2) → 3. range(-5, 5) → 4. range(1, -1, -1) → 5. range(0) →
1. 1 3 5 7 9 2. 10 8 6 4 2 3. -5 -4 -3 -2 -1 0 1 2 3 4 4. 1 0 5. empty
The following statement will check to see if the turtle's pen color is 'green': if turtle.pencolor() = 'green'
F
What will the following statement displays? print('George', 'John' , 'Paul', 'Ringo' , sep='@')
George@John@Paul@Ringo
IDLE is an alternative method to using a text editor to write, execute, and test a Python program.
T
The following code snippet will change the turtle's pen size to 4 if it is presently less than 4: if turtle.pensize() < 4: turtle.pensize(4)
T
Can a function return more than one values?
Yes
What is the output of this code? numbers = [5, 7, 11, 13, 17, 19, 29, 31] numbers[1] = 3 del numbers[3] numbers[3] = 37 numbers[4] = numbers[5] print(numbers)
[5, 3, 11, 37, 29, 29, 31]
Rewrite the code shown below so it uses a while loop instead of a for loop. Your code should behave identically. (6 points) for a in range(-100, 100, 10): print('*', end='') print()
a = -100 while a < 100: print('*', end='') a=a+10 print()
Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.
print(format(sales, '.2f'))
What is the binary value of the following decimal number? 118 a. 01110110 b. 11001000 c. 00111001 d. 01110101
A
What is the decimal value of the following binary number? 10011101 a. 157 b. 8 c. 156 d. 28
A
Which of the following is the correct if clause to determine whether choice is anything other than 10? a. if choice != 10: b. if choice != 10 c. if choice <> 10: d. if not(choice < 10 and choice > 10):
A
Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive? a. if y >= 10 and y <= 50: b. if 10 < y or y > 50: c. if 10 > y and y < 50: d. if y >= 10 or y <= 50:
A
What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8? not (x < y or z > x) and y < z a. False b. True c. 8 d. 5
A. False
What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x a. True b. False c. 8 d. 5
A. True
A(n) __________ structure is a logical design that controls the order in which a set of statements execute. a. function b. control c. sequence d. Iteration
B
Programs are commonly referred to as a. system software b. software c. application software d. utility programs
B
How many times will "Hi again!" be displayed after the following code executes? for i in range(0, 12, 2): print("Hi, again!") a. 2 b. 12 c. 5 d. 6
D
The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level language.
F
Write Python code that prompts the user to enter his or her height and assigns the user's input to a variable named height.
height = int(input('Enter your height: '))
Write a for loop that iterates over a list of numbers lst and prints the even numbers in the list. For example, if lst is [ 2, 3, 4, 5, 6, 7, 8, 9]. Then the numbers 2,4,6, and 8 should be printed.
lst = [ 2, 3, 4, 5, 6, 7, 8, 9] for i in lst: if i%2==0: print(i, end=' ')
The following is an example of an instruction written in which computer language? 10110000 a. Assembly language b. Java c. machine language d. C#
C
sum(2,4,6) sum([1,2,3]) a. Error, 6 b. 12, Error c. 12, 6 d. Error, Erro
A
What will be displayed after the following code is executed? counter = 1 while counter <= 20: print(counter, end=" ") counter *= 3 print("\nThe loop has ended.") a. 1 3 9 The loop has ended. b. 1 3 9 The loop has ended. c. 1 3 9 12 15 18 The loop has ended. d. 1 3 9 The loop has ended.
A
When using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true. a. or b. and c. not d. Maybe
A
Where does a computer store a program and the data that the program is working with while the program is running? a. in main memory b. in the CPU c. in secondary storage d. in the microprocessor
A
Which computer language uses short words known as mnemonics for writing programs? a. Assembly b. Java c. Pascal d. Visual Basic
A
Which logical operators perform short-circuit evaluation? a. or, and b. or, not c. not, and d. and, or, not
A
Which type of error prevents the program from running? a. syntax b. human c. grammatical d. logical
A
For the following code, what will the result be if the user enters 5 at the prompt? sum = 0 end_value = int(input("Enter a number: ")) for i in range(1, end_value): sum = sum + i print(sum, end=", ") a. 10, b. 1, 3, 6, 10, c. 1, 3, 6, 10, 16, d. 1, 2, 3, 4, 5,
B
What will the output of the following code be if the user enters 3 at the prompt? your_num = int(input("Enter a number:")) while (your_num > 0): product = your_num * 5 print(your_num, " * 5 = ", product) your_num -= 1 a. 3*5 = 15 b. 3*5 = 15 2*5 = 10 1*5 = 5 c. 3 * 5 = 15 3 * 5 = 15 3 * 5 = 15 d. 3 * 5 = 15 2 * 5 = 10 1 * 5 = 5 0 * 5 = 0
B
What is the output? i = 0 while i < 25: i = i + 5 print('hello')
hello hello hello hello hello
What is the output? sum = 0 for i in range(0, 25, 5): i += 2 print('hello')
hello hello hello hello hello