Python

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

Which two factors affect the cost of an algorithm? Choose 2 answers

Time Memory

What is one purpose of the Python + operator?

To concatenate strings

What is an algorithm?

A finite set of steps for performing a task or solving a problem

Given the following Python code: felines = ['lions', 'tigers', 999, 'housecats'] my_feline = felines.pop(1) What does my_feline contain after the second statement executes?

'tigers

What is a programming language library?

A set of related modules, possibly precompiled

What does UML provide?

A way to visually model computing applications

When should a use case be written?

After gathering requirements

A portion of a list of steps to sort a deck of cards is given below: 1) If the stack of cards is empty, or it only contains one card, it is sorted; you are done. 2) Take the stack of cards. Look at the first card (the top) of the stack. 3) The card you are looking at is card A. The position where card A currently, is in stack P. 4) If there are no more cards in the stack after card A, go to step 8. 5) The next card in the stack is card B. 6) If card B has a lower number than card A, swap the positions of cards A and B. Which programming concept does this sequence of steps represent?

Algorithm

Given following Python code: States = [['arkansas', 'little rock', 38], ['new york', 'new york', 2], ['california', 'sacramento', 1], [ 'alaska', 'juneau', 50]] Which statement would correctly locate 'sacramento'?

States [2] [1]

A biologist wants to process water salinity measurements until water temperature falls below a certain level. Which control structure supports this biologist's needs?

While loop

Which control structure repeatedly tests the expression and, if it is true, executes the statements in the body of the structure?

While loop

When analyzing algorithms, which case is the most important to consider?

Worst case

Which execution time determines the overall efficiency of an algorithm?

Worst-case

Refer to the following Python list: direction = ['top', 'down', 'left', 'right'] Which Python statement replaces ' top' with ' up'?

direction[0] = 'up'

A manager at a large company would like to know the total of the salaries of all of the employees in the manager's department so the manager can complete a budget. Given the following list of the manager's employee's salaries (in thousands): salary = [60, 70, 90, 50] total=0 In Python, which for loop code will print a total of the salaries for the manage

for e in salary: total = total + e print total

When creating a class diagram, which aspects should you define for each class? Choose 2 answers

Name Attribute & Method

Which two statements about object-oriented design (OOD) are true? Choose 2 answers

OOD emphasizes defining objects and their relationships to fulfill the requirements identified during the analysis phase. A class diagram is an OOD deliverable that describes the static structure of a system by showing the system's classes, their attributes, and the relationships between the classes.

Given the following class definitions related to an office: class OfficeTech(object): class OfficeSupplies(object): class Paper(OfficeSupplies): class Monitor(OfficeTech): class OfficeFurniture(object): class StickyNotes(Paper): class Pens(OfficeSupplies): class Chair(OfficeFurniture): Which classes inherit from OfficeSupplies?

Paper, StickyNotes, Pens

Which operator is used to concatenate strings?

+

Given the following computer program statements: days = 12 days = days - 2 * 2 What is the final value of days after running the code

8

Which operator is a comparison operator?

==

How does a hash-based index increase lookup speed?

By mapping a given keyword to its index

What is a user-defined prototype for an object?

Class

Which storage method ensures the fastest access to input data?

Dictionaries

What is the correct grammar rule for a programming expression?

Expression -> Expression Operator Expression

Match each term with the correct description. Answer options may be used more than once or not at all. Select your answers from the pull-down list

For loop -Uses a counter to control iteration While loop - Iterates until a condition is satisfied if... else - Takes one course of action if a condition is satisfied and a second otherwise

Given the following variable assignment: Greeting = "Good Morning world!" Greeting = "I'm ready to start my day!" What is the value of the variable Greeting?

I'm ready to start my day!

Which term describes strings that cannot be changed?

Immutable

What is an example of a comparison programming expression

Inequality

What is a parameter?

It is an input to a procedure.

What is the correct rule regarding the number of elements a Python list may contain

It must be a sequence of zero or more elements.

What is the purpose of an if-else statement?

It provides a way to control what code executes.

Which language is built on object-oriented design principles?

Java

Which of the following can hold data of multiple types? Choose 2 answers

List Dictionary

What does a use case diagram do?

Provides an overview of several use cases

Which programming language is best used for developing web apps?

Python

Given the following Python code: def fib_rec(n): if n==1 or n==2: return 1 else: return fib_rec(n - 2) + fib_rec(n - 1) Which programming technique is this code an example of?

Recursion

What is being measured when a programmer measures how algorithm speed varies with the amount of input?

Scalability

What does inheritance afford in object-oriented programming?

The ability to override behavior from another class

Which aspect of a programming language would not likely affect the execution time (speed) of a program?

The compiler

What is necessary for an entity to be considered an actor in a use case?

The entity needs to exist outside the described system.

What is the definition of instantiation?

The object that is created from a class

What is usually the main factor that determines the speed of an algorithm?

The size of input

What are two advantages of using functions in programs? Choose 2 answers

They increase code modularity. They reduce code duplication.

What is an advantage of using programming libraries?

They save development time.

A class has a specified number of students. The teacher would like to print out each of the student's names and their final grade. Given the following code: student_grades= [['Mel', 'A'],['Joe', 'B'],['Bob', 'C'],['Rob', 'D']] _________________ print grade Which for loop code should be placed in the blank space to accomplish this task?

for grade in student_grades:

Refer to the following code: m = 0 while _______: print 'Hello' Which Python expression will cause this code to print 'Hello' indefinitely?

m == 0

Given the following Python code: A = True B = False result = not (A __ B) or not x Which operator must be substituted for the underscore and which variable must be substituted for x to give the result a final value of False?

or, A

What is the list operation in Python that will remove a specified element?

pop

Given the following pseudocode code: identity = 'Person A' friend = 'Person B' Which statement will display ' We are Person A and Person B'?

print 'We are ' + identity + ' and ' + friend

Given the following pseudocode: x = 25 y = 46 if x > y: print 'larger' else: print 'smaller' What will be displayed?

smaller


Kaugnay na mga set ng pag-aaral

El Conditional Tense. Realidades 3 pag. 352 "You use the conditional in Spanish to express what a person would do or what a situation would be like"

View Set

CodePath Data Structure Patterns

View Set

Interior Design Chapters 4-6 and 1 Munsell

View Set

Chapter 43: Hematological or Immunological Pediatric

View Set

data analysis chapter 11 study guide

View Set

Biology, Light Independent Reactions in Photosynthesis

View Set

NUTR 251 - Smartbook Ch. 13 - Water-Soluble Vitamins

View Set