Programming Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which statement about the procedural paradigm is false?

The procedural paradigm is characterized by the use of inheritance, polymorphism, and encapsulation.

How is a variable's data type determined in Python?

The variable's type is inferred based on the presence or absence of a decimal point and quote marks.

The following program code follows the correct Python syntax for an if-then structure. 1 print("Is today your birthday? Enter") 2 isBirthday = input("Yes or No: ") 3 if isBirthday == "Yes": 4 print("Happy birthday to you!") 5 print("Have an awesome day!")

True

Suppose a programmer is functionally decomposing a two-factor authentication process. Which step requires further decomposition before it can become a step in an algorithm?

Validate that user ID and password match.

Which statement describes the relationship between variables and memory?

Variable names correspond to memory locations.

You and a friend are inside your favorite quick-serve restaurant, preparing to place an order at the kiosk. All meals are served with a drink and a bag of chips or pretzels. You have reached the display area on the kiosk where you can enter your meal request. You both want the turkey sandwich meal because it is on special this week: it includes two sandwiches for the price of one. You select two meals. Now, imagine that you are reviewing the kiosk design. Based on the following kiosk pseudocode, what is displayed on the screen when line 9 executes? line 1: initialize drink_count = 0 line 2: initialize snack_bag_count = 0 line 3: initialize turkey_sandwich_count = 0 line 4: initialize turkey_sandwich_meal_count = 0 line 5: initialize order_correct = True line 6: display "Hello! How many turkey sandwich meals would you like?" line 7: input turkey_sandwich_meal_count line 8: display "Please verify your order. " line 9: display "You would like " turkey_sandwich_meal_count " turkey sandwich meals today, correct? "

You would like 2 turkey sandwich meals today, correct?

In order to create software for a digital device, a developer can specify the steps in the procedures that the device should perform using a special notation called _____.

a programming language

Which term refers to a technique that hides details, simplifies complexity, and substitutes a generalization for something specific?

abstraction

Which term refers to a series of finite steps for solving a problem or carrying out a task?

algorithm

Which idea represents an example of a repetitive pattern?

allowing three password entry attempts before locking a user out of an online account

What is the logical operator in the following code? choice = input() if choice > 3 and choice != 9: print("Invalid input.")

and

Which phrase describes a literal in the context of a programming language?

any element of data specified for a program

Which statement should you place in the blank of the following Python code if you want to add an assignment statement that changes the value of the variable apple_pies ? apple_pies = 4 _____

apple_pies = apple_pies + 2

One key characteristic common to programming languages is _____.

arithmetic operators that can be used to perform calculations

It is most likely not necessary to incorporate conditions or decisions in an algorithm used to _____.

assign the same letter grade to all students' quiz results

The not operator is used _____.

before a conditional expression to flip a Boolean value to its opposite

Which phase describes an example of functional decomposition?

breaking down a two-factor authentication module into smaller actions, processes, or steps

A computer's _____ processes input and produces output according to the instructions supplied by a software program stored in memory.

central processing unit (CPU)

You are given the following program code. What values for the variables high_temperature_today and chance_of_rain will cause the program to output the message to "Bring your light jacket"? print("Enter today's predicted high temperature.") high_temperature_today = input() print("Enter today's predicted chance of rain.") chance_of_rain = input() if chance_of_rain > 80.00 or high_temperature_today < 50: print("Bring your heavy rain coat.") else: print("Bring your light jacket.")

chance_of_rain = 20.00 and high_temperature_today = 60

You are given the following program code. What values for the variables high_temperature_today and chance_of_rain will cause the program to output the message to "Bring your heavy rain coat"? print("Enter today's predicted high temperature.") high_temperature_today = input() print("Enter today's predicted chance of rain.") chance_of_rain = input() if chance_of_rain > 80.00 and high_temperature_today < 50: print("Bring your heavy rain coat.") else: print("Bring your light jacket.")

chance_of_rain = 85.00 and high_temperature_today = 40

Jen's favorite application helps her write clean code by color-coding keywords, directives, and punctuation as she types them to make these elements easy to recognize without including any hidden symbols in the code files she sends to her programming language. Jen's favorite application is a _____.

code editor

Which tool is specially designed for entering high-level programming code without including extraneous symbols?

code editor

What are the three essential programming tools programmers should either install on their computers or access online?

coding tools, build tools, debugging tools

To select an efficient algorithm for a use case, a programmer uses a set of techniques designed to formulate problems and their solutions known as _____.

computational thinking

Which phrase describes character and string literals?

data such as letters, symbols, words, and sentences

What term refers specifically to the process of dividing a complex problem into smaller parts?

decomposition

Which phrase describes an example of structural decomposition?

diagramming a mobile banking app as a hierarchy of building-block units

Which shape is used to indicate a decision point in an if-then flowchart?

diamond

Which programming language convention tells the computer how to handle the program rather than how to perform an algorithm?

directive

Which action can cause a runtime error in a program?

dividing a number by zero

Which term refers to code that is stored in an executable file that can be run, processed, and executed by the microprocessor?

executable code

Which term refers to program execution that continues to the next conditional statement within a structure?

fall through

The phases of the instruction cycle are _____.

fetch, interpret, and execute

Imperative programming paradigms focus on _____, whereas declarative programming paradigms focus on _____.

how; what

Because the procedural paradigm focuses on step-by-step algorithms, it is classified as a(n) _____ programming paradigm.

imperative

Machine language op codes correspond directly to the _____ of a CPU.

instruction set

A(n) ____ is a software utility that begins with the first statement in a program, preprocesses it into a binary instruction, and then executes it.

interpreter

Which action will cause a syntax error?

leaving a keyword out of a statement

Which line of code in the following Python program represents a conditional statement? 1 print("Press Y when you are ready to") 2 choice = input("begin the exam: ") 3 if choice == "Y": 4 print("You entered " + choice) 5 print("Notifying your proctor.") 6 print("Good luck!")

line 3: if choice == "Y":

Which list consists of examples of the declarative paradigm?

logic programming, functional programming, and database query programming

Which idea represents an example of a fill-in-the blank pattern?

looking for patterns in an algorithm that allow the algorithm to work for any input number value

Which phrase describes an example of object-oriented decomposition?

looking for two-factor authentication logical and physical objects that a computer program will manipulate

Which characteristic refers to an advantage of high-level programming languages?

machine independent

A(n) _____ is a complex integrated circuit containing billions of components designed to process data.

microprocessor

Which list identifies the keys components of an integrated circuit?

microscopic transistors, resistors, capacitors, and circuitry

Which term refers to the code produced by a compiler?

object code

The _____ paradigm relies on creating data models of a problem's entities, actions, and relationships.

object-oriented

A machine language instruction has an _____ that specifies an operation, and can also have one or more _____ that specify the data to process, its location in memory, or its destination in a register.

op code; operands

Which pseudocode statement correctly initializes the Boolean variable paid_in_full using an assignment statement?

paid_in_full = True

Which term refers specifically to the process of finding similarities in procedures and tasks?

pattern identification

The = operator ____, while the == operator ____.

places a value in a variable; checks to see if two operands are equal to each other in content

Which characteristic of object-oriented programming allows the same behavior to be implemented in different ways for different children of a parent class?

polymorphism

An effective algorithm _____.

produces one or more outputs

Which term refers to a tool that assists a programmer in writing program code?

program editor

The various approaches to programming are referred to as _____.

programming paradigms

____ represents a variable created using camel case and ____ represents a variable created using snake case.

redSoxInventoryCount; red_sox_inventory_count

Which characteristic refers to a disadvantage of high-level programming languages?

require translation

A compiler uses ____ as input and generates ____ as output.

source code; object code

Which parts of the following algorithm require decision control structures? Line 1: Output "Welcome to the quick self-serve order kiosk." Line 2: Output "Press 1 to order from our sandwich menu." Line 3: Output "Press 2 to order from our side items menu." Line 4: Output "Press 3 to order from our drink menu." Line 5: Output "Press 9 to place your order and end your session." Line 6: Display the sandwich menu. Line 7: Display the side items menu. Line 8: Display the drink menu. Line 9: Ask the customer to provide a name for the order. Line 10: Ask the customer to indicate their payment type. Line 11: Provide payment type acceptance status. Line 12: Output order pick-up ticket/receipt.

the options in lines 2 through 5

Which phrase describes Boolean literals?

the words True and False not enclosed in single or double quotes

Which statement can be used to initialize a variable in Python?

total_rings = 20

Which component is considered one of the most important elements in an integrated circuit because of its roles as an amplifier and a switch?

transistor

Moore's Law states that the number of components in manufactured integrated circuits doubles every _____ years.

two

Which action can cause a logic error in a program?

using the wrong expression for a decision

To write a program using the procedural paradigm, you must _____.

visualize the program as a step-by-step algorithm

When using IDLE, you choose shell mode _____.

when you want to quickly test lines of code

When writing an if-then structure in pseudocode, _____.

you make a conditional statement that begins with "if"

When you declare a variable in Python, _____.

you must assign a value to that variable at the same time

As a summer intern, you have been asked to create a database record layout for storing employee information. The record will contain the following fields: The employee's full name (first, middle, and last) Street address (allow two lines) City State Zip code Home area code Home phone number Cell phone area code Cell phone number Employee birthdate (mm/dd/yyyy) Age, calculated using the birthdate and system current date (updated nightly) Gender Start date at the organization (mm/dd/yyyy) Number of years employed, calculated using the start date and system current date (updated nightly) The employee's last four Social Security number digits Which database fields will be represented as string literals?

zip code and cell phone area code

Which list of literals contains only integer and floating-point literals?

0b00000011, 3, 0x3C

The ____ relational operator describes two operands that are equal to each other, while the ____ relational operator describes two operands that are not equal to each other.

==; !=

Which statement describes how the black box concept is an implementation of abstraction?

A black box produces an output while hiding the inner workings of a process.

Which sentence best describes the purpose of a control structure?

A control structure is used to alter the sequential execution of statements in a computer program.

Which statement helps to explain the difference between a variable, a constant, and a literal?

A literal is a data element, but a constant is a place in memory that holds a value that does not change.

Which example illustrates how a class can be used as an abstraction?

A programmer creates a class to handle a recognized pattern of attributes required to describe a glassware product.

Which example illustrates how abstraction can help identify variables?

Abstraction can be used in pattern recognition to identify possible variables.

What statement describes how dependencies and cohesion relate to decomposition?

An effective breakdown minimizes dependencies and maximizes cohesion among the various parts.

Which of the following programming languages is most prevalent in object-oriented applications today?

C++

The _____ for each of your digital devices is housed in a single integrated circuit called a _____.

CPU; microprocessor

Which statement accurately describes the declarative paradigm?

Declarative programs specify what a program is supposed to accomplish, not how to accomplish it.

Why are computer scientists interested in algorithm efficiency?

Efficient algorithms tend to produce computer programs that operate efficiently, quickly, and reliably.

Which early high-level programming language is associated with the procedural programming paradigm?

Fortran

_____ languages provide easy-to-remember command words.

High-level programming

When you install Python, it comes with a built-in, easy-to-use integrated development environment called _____.

IDLE

Why is decomposition an important tool for computer scientists?

It creates algorithm designs with more manageable pieces, leading to programs that are more efficient and maintainable.

Which statement describes a feature of an integrated development environment (IDE)?

It includes all the tools a programmer needs to code, compile, link, and debug their work.

Which statement best describes a computer program?

It is a set of instructions that performs a specific task when executed by a digital device.

Which statement best describes a software development kit (SDK)?

It is a set of tools for developing platform-specific software.

Which statement describes why abstraction is an important computer science concept?

It provides a means to hide implementation details from the user to simplify subsequent development and promotes software reuse.

Which sentence best describes the purpose of a constant?

It provides a named location in memory that holds a value that does not change, making programming code changes easier.

Which language is an example of an early high-level programming language?

LISP

Which list identifies three of the most common operations in a microprocessor instruction set?

LOAD, MOVE, ADD

Which statement describing characteristics of declaring, initializing, and assigning variables is false?

Later in a program, a programmer cannot use an assignment statement to change the value of a variable.

Given the following Python code for a design-your-own soft drink dispenser, which statements belong in the blanks? 1 print("Press 1 for caffeinated") 2 print("beverages, or press any") 3 print("other kay for non-caffeinated.") 4 bevType = input() 5 _____ 6 print("You chose caffeinated.") 7 print("Loading caffeinated menu!") 8 _____ 9 print("You chose non-caffeinated.") 10 print("Loading non-caffeinated menu!")

Line 5: if bevType == "1": Line 8: else:

Given the following pseudocode for a quick-serve restaurant's kiosk menu selection algorithm, what statements belong in the blanks to complete the if-then-else structure? 1 output "Press 1 when you are ready to" 2 output "start your menu order at this kiosk." 3 output "Press any other key to quit." 4 input choice 5 _____ 6 output "Great! Let's begin." 7 jump to menu algorithm 8 _____ 9 output "You chose to quit." 10 output "Goodbye!"

Line 5: if choice = 1 ; Line 8: else

Which statement describing machine language is false?

Machine language uses text abbreviations to represent computer operations.

Programming languages such as _____ support the _____ programming paradigm, and thus the declarative approach.

Prolog; logic

Which language is an example of a modern, high-level programming language that is currently in widespread use?

Python

Which item is the name of a popular programming language?

Ruby

Which statement describes a characteristic of semantics in the context of programming languages?

Semantics refers to the meaning and validity of program statements.


Ensembles d'études connexes

Chapter 89: Drug Therapy of Urinary Tract Infections

View Set

Lesson 7: Quartiles, Quantiles, and Interquartile Range

View Set

Combo with NOBCChE Science Bowl: EARTH SCIENCE Set 1 and 16 others

View Set

ABNORMAL PSYCH FINAL Study Guide

View Set