CIS40 Python Final Study Guide

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Consider the following code segment: a = input("Enter the value of a: ") b = input("Enter the value of b: ") print(a + b) When this code segment is run the user enters 1 at the first prompt and 5 at the second prompt. The output displayed is: 1 6 15 1 + 5

15

What is returned by the following function if x = 5.64? round(x) 1) Nothing, there is an error in the statement 2) 5 3) 5.6 4) 6

6

Which type of error is usually the most difficult to locate in your program? 1. Indentation Error 2. Logic Error 3. Syntax Error 4. Zero Division Error

Logic Error

Which parts of the computer store program code? 1. CPU 2. Secondary storage 3. Monitor 4. Keyboard

Secondary storage

Which function call will cause Python to report an error? abs(1, 2) max(1, 2) min(1, 2) round(1, 2)

abs(1, 2)

print(25 + 84) 1. 2584 2. 109 3. 25 + 84 4. Nothing, this code snipped causes a compile time error

109

length = len("Good Morning") 10 11 12 13

12

What is the difference between an editor and an interpreter? 1. An editor allows program files to be entered and modified; an interpreter reads and executes program files 2 An editor allows program files to be entered and modified; an interpreter produces an indexed database of terms and keywords 3. An editor allows program files to be entered and modified; an interpreter produces an organized list of files 4. An editor converts program files into an executable program; an interpreter allows program files to be entered and modified

An editor allows program files to be entered and modified; an interpreter reads and executes program files

s = "abcde" i = 1 while i < 5 : if i > 1 : print(s[i]) No output No output (infinite loop) abcde bcde

No output (infinite loop)

What is another name for a compile-time error? 1. Logic error 2. Semantic error 3. Syntax error 4. Lexicographic error

Syntax error

When the computer begins to run a program, 1. the program is moved from secondary storage to memory. 2. the program is moved from secondary storage to the network controller. 3.the program is moved from the CPU to memory. 4.the program is moved from the CPU to secondary storage.

The program is moved from secondary storage to memory.

The following logical expression will 'short-circuit'... quantity > 0 and price/quantity < 10 When |quantity| is equal to 0 When |quantity| is equal to 5 When |price/quantity| is less than 10 When |price/quantity| is greater than 10

When |price/quantity| is greater than 10

What is supplied to a function when it is called? arguments numbers return values variables

arguments

Which statement draws a square on the canvas? canvas.drawRect(0, 50, 0, 50) canvas.drawRect(50, 50, 0, 0) canvas.drawRect(0, 0, 50, 100) canvas.drawRect(0, 0, 50, 50)

canvas.drawRect(0, 0, 50, 50)

What range of numbers are generated by the random() function? 1. greater than or equal to zero and less than or equal to one 2. greater than zero and less than one 3. greater than zero and less than or equal to one 4. greater than or equal to zero and less than one

greater than or equal to zero and less than one

Which of the given print statements generates the following output? ABCDE"\ print("ABCDE\"\\") print("ABCDE"\") print("ABCDE"\) print("ABCDE\"\")

print("ABCDE\"\\")

What is the correct sequence of steps invoked by the Python Interpreter: 1. source code -> virtual machine -> byte code -> compiler 2. source code -> compiler -> byte code -> virtual machine 3. compiler -> source code -> virtual machine -> byte code 4. byte code -> virtual machine -> source code -> compiler

source code -> compiler -> byte code -> virtual machine

name = "today is thursday" name.replace("t", "T") name.replace("i", "I") print(name) today is thursday Today is Thursday Today Is Thursday Today Is thursday

today is thursday


संबंधित स्टडी सेट्स

Practical Aviation & Aerospace Law Ch 1: "Regulatory Agencies and International Organizations"

View Set

Chapter 51: Care of the Patient with a Reproductive Disorder

View Set