CIS 41A Chapter 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following is considered a stringin Python? 1.Today is Wednesday 2."Today is Wednesday" 3.# Today is Wednesday # 4.Today_is_Wednesday

"Today is Wednesday"

.Which of the following statements is most correct? 1.Computer programs are comprised of a large number of simple instructions. 2.Computer programs are comprised of a large number of sophisticated instructions. 3.Computer programs are comprised of a small number of simple instructions. 4.Computer programs are comprised of a small number of sophisticated instructions.

.Computer programs are comprised of a large number of simple instructions.

What extension is used for Python files? 1..Python 2..py 3..dat 4..tx

.py

The Python compiler reads the file containing your source code and converts it to: 1.machine code 2.assembly code 3.byte code 4.virtual machine code

byte code

Which of the following pseudocode statements represents a repetition statement? 1.if total cost > 15 2.set i equal to 3 3.total cost = unit cost + tax 4.while the balance is > 0

while the balance is > 0

Which line in the following program is a comment line? 1: print("Your lucky number is...") 2: lucky = 7 3: # Display the lucky number 4: print(lucky) 1.Line number 1 2.Line number 2 3.Line number 3 4.Line number 4

Line number 3

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

The programmer, not the compiler, is responsible for testing a program to identify what? 1.Undefined symbols 2.Syntax errors 3.Logic errors 4.Out-of-memory errors

Logic errors

Consider the following pseudocode. What does it produce? Set a = 0 Set b = 0 Set c = 1 Set d = 1 Report the value of d Repeat until a equals10 Set d = b + c Set b = c Set c = d Add 1 to a Report the value of d 1.1 1 2 3 5 8 13 21 34 55 89 2.1 1 3 5 7 9 11 13 15 17 19 21 3.1 1 3 6 9 12 15 18 21 24 27 30 4.1 2 3 4 5 6 7 8 9 10 11

1 1 2 3 5 8 13 21 34 55 89

What is printed by the following code snippet?print(25 + 84) 1.2584 2.109 3.25 + 84 4.Nothing, this code snipped causes a compile time error

109

What is printed by the following code snippet?print("25 + 84") 1.2584 2.109 3.25 + 84 4.Nothing, this code snipped causes a compile time error

25+84

Which of the following is NOT an example of an algorithm? 1.A recipe to make chocolate chip cookies 2.A grocery list 3.Instructions for changing a flat tire 4.Steps required to calculate the amount of paint required to paint a room

A grocery list

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

An integrated development environment bundles tools for programming into a unified application. What kinds of tools are usually included? 1.A web browser 2.An editor and an interpreter 3.Presentation tools 4.Source files and bytecode files

An editor and an interpreter

What part of the computer carries out arithmetic operations, such as addition, subtraction, multiplication, and division? 1.CPU 2.Network 3.Primary storage 4.Secondary storage

CPU

hat is printed by the following code snippet?print("Good", "Morning", "Class", "!")1.GoodMorningClass!2.Good Morning Class!3.Good Morning Class !4.nothing, this code produces a syntax error

Good Morning Class !

What is printed by the following code snippet? print(Hello) 1.Nothing, an error is produced indicating that Hellois not defined 2.Hello 3.'Hello' 4."Hello"

Nothing, an error is produced indicating that Hello is not defined

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

Secondary storage

The following pseudocode calculates the total purchase price for an item including sales tax, what is the missing last line?Start by setting the total cost to zero.Ask the user for the item cost.Ask the user for the taxrate.Set the item tax to item cost times tax rate. _________________________________ 1.Set the total cost to the item cost plus the tax rate. 2.Set the total cost to the item cost times the tax. 3.Set the total cost to the item cost plus the tax. 4.Set the total cost to the item tax.

Set the total cost to the item cost plus the tax

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

Syntax error

. Imagine that you are planning to buy a new cell phone. After doing some research, you have determined that there are two different cell phones that will meet your needs. These cell phones have different purchase prices and each mobile service provider charges a different rate for each minute that the cell phone is used. In order to determine which cell phone is the better buy, you need to develop an algorithm to calculate the total cost of purchasing and using each cell phone. Which of the following options lists all the inputs needed for this algorithm? 1. The cost of each cell phone and the rate per minute for each cell phone 2. The cost of each cell phone and the number of minutes provided with each cell phone 3. The cost of each cell phone, the rate per minute for each cell phone, and the number of minutes provided with each cell phone 4. The cost of each cell phone, the rate per minute for each cell phone, and the number of minutes you would use the cell phone

The cost of each cell phone, the rate per minute for each cell phone, and the number of minutes you would use the cell phone

Although the following code statement is valid, print(10/0), what will happen when this code is executed? 1.The program prints 0 2.The error message ZeroDivisionError: int division or modulo by zero is displayed 3.The program runs, but nothing is printed 4.The error message SyntaxError: EOL while scanning string literal

The error message ZeroDivisionError: int division or modulo by zero is displayed

What is the purpose of the following algorithm, written in pseudocode?num = 0Repeat the following steps 15 timesAsk user for next numberIf userNum > num num = userNumPrint num 1.To print out the 15 numbers 2.To find the smallest among 15 numbers 3.To search for a particular number among 15 numbers 4.To find the highest among 15 numbers

To find the highest among 15 numbers

What is the purpose of a comment? 1.A comment provides information to the virtual machine 2.A comment provides information to the compiler 3.A comment provides information to the programmer 4.A comment provides information to the user running the program

a comment provides information to the programmer

A Python interpreter is: 1.a folder hierarchy 2.a piece of hardware 3.apiece of software 4.a type of secondary storage

a piece of software

Which of the following items is NOT considered hardware? 1.a keyboard. 2.a speaker. 3.a program. 4.a microphone.

a program

A sequence of characters enclosed in quotes is called :1.a string 2.a list 3.a function 4.an argument

a string

What is it called when you describe the steps that are necessary for finding a solution to a problem in programming? 1.algorithm 2.compile 3.interpret 4.code

algorithm

Consider the following pseudocode. What does it produce? Create a list of consecutive integers from two to n (2, 3, 4, ..., n).Initially, let p equal 2.Repeat the following steps until p is greater than n:Remove all of the multiples of p less than or equal to n from the list. If the list contains a number greater than pFind the first number remaining in the list greater than p.Replace p with this number.Otherwise set p equal to n + 1 1.All even numbers up to n 2.All factorial numbers up to n 3.All odd numbers up to n 4.All prime numbers up to n

all odd numbers up to n

A sequence of steps that is unambiguous, executable, and terminating is called: 1.a logarithm 2.a programming task 3.an algorithm 4.pseudocode

an algorithm

When a function is called, the values placed in parentheses are referred to as: 1.arguments 2.keywords 3.operators 4.statements

arguments

What are two of the most important benefits of the Python language? 1.Advanced mathematical equations and fast programs 2.Ease of use and fast programs 3.Ease of use and portability 4.Fast programs and smaller programs

ease of use and portability

Computers are machines that: 1.are imprecise and slow. 2.design computer programs. 3.execute programs. 4.carry out a very narrow range of tasks.

execute programs

A collection of programming instructions that carry out a particular task is called a: 1.program 2.compiler 3.function 4.comment

function

Which of the following pseudocode statements represents a decision ?1.For each number in a sequence... 2.While the balance is > 0 3.total cost = unit cost + tax 4.if total cost > 15

if total cost > 15

A computer program is a sequence of: 1.ones and zeroes. 2.instructions and decisions. 3.primary and secondary storage. 4.processors and compilers.

instructions and decisions

By entering the command python3, the program runs in which mode? 1.interactive mode 2.print mode 3.command mode 4.backup mode

interactive mode

In order to run Python programs, the computer needs to have software called a(n)? 1.debugger 2.interpreter 3.windows 4.assembler

interpreter

What reads Python programs and executes the program instructions? 1.editor 2.CPU 3.compiler 4.interpreter

interpreter

High-level programming languages were created to: 1.Allow programmers to describe the solution to a problem one CPU instruction at a time 2.Make programming less error-prone and less tedious 3.Maximize the running time of programs 4.Translate CPU instructions into high-level instructions

make programming less error-prone and less tedious

Which of the following hardware devices is NOT considered an output device? 1.Speaker 2.Monitor 3.Printer 4.Microphone

microphone

Which of the following hardware devices is NOT considered an input device? 1.Keyboard 2.Monitor 3.Mouse 4.Microphone

monitor

The Central Processing Unit is primarily responsible for: 1.ensuring data persists when electrical power is turned off. 2.enabling a human user to interact with the computer. 3.interconnecting computers that are separated by distance. 4.performing program control and data processing.

performing program control and data processing

Which of the following code segments will display Hello World!when it is run? 1.print(Hello "," World"!") 2.print("Hello", "World!") 3.print("Hello", "World", "!") 4.print("Hello", ",", "World", "!")

print("Hello", "World!")

Which of the following statements is NOT correct? 1.Pseudocode should be unambiguous. 2.Pseudocode should be executable. 3.Pseudocode should be properly formatted. 4.Pseudocode should be terminating

pseudocode should be properly formatted

What is wrong with the following code snippet:num1 = 10 num2= 20 num3 = 30total = Num1 + Num2 + Num3 1.Nothing, the variabletotalwill be the sum of the three numbers 2.Python is case sensitive soNum1,Num2, andNum3are undefined 3.totalmust be initialized to zero first 4.The numbers should be10.0, 20.0and30.0

python is case sensitive so Num1, Num2, and Num3 are undefined

Which of the following is NOT a benefit of the Python programming language compared to other popular programming languages like Java, C, and C++? 1.Python encourages experimentation and rapid turn around 2.Python has a cleaner syntax 3.Python is easier to use 4.Python programs run more quickly

python programs run more quickly

Computers store both data and programs not currently running in: 1.Primary storage. 2.Central processing unit 3.Secondary storage. 4.Transistors

secondary storage

Which of the following refers to a collection of programs that a computer executes? 1.Compiler 2.Software 3.Instructions 4.Source Code

software

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

What is printed by the following code snippet? print("The answer is", 25 + 84) 1.The answer is 2584 2.The answer is 109 3.The answer is 25 + 84 4.Nothing, this code snipped causes a compile time error

the answer is 109

What is printed by the following code snippet?print("The answers are:", 4 + 3 * 2, 7 * 5 -24) 1.The answers are: 10 11 2.The answers are: 14 11 3.The answers are: 24 10 4.Nothing, this code snipped causes a compile time error

the answers are: 10 11

To use or call a function, you need to specify: 1.the function name and its arguments 2.the function name only 3.the function name and at least one argument 4.the function name and a comment describing its use

the function name only

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

What is wrong with the following code snippet? print("Hello")print("World!") 1.The print function cannot be called twice 2.The print function is missing an argument 3.Nothing, the program prints Hello Worldon the same line 4.The second line should not be indented

the second line should not be indented


Set pelajaran terkait

O'Gorman HS Speech Comm. Semester Final

View Set

19: Magnesium, Zinc, Tin, and Specialty Metals

View Set

DSHEA and Regulation of Natural Products

View Set

(PS 6440) Vocabulary of Public Administration

View Set

Free fall, Speed, Acceleration, and Velocity

View Set

Narrative Tenses - 200 sentences

View Set

Intensive and Reflexive Pronouns

View Set