Intro to Python Module 1

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

A legacy program is outputting values in octal format, and you need to translate the octal to hexadecimal. What is 173 in octal expressed as a hexadecimal value?

7B

Regardless of whether print is passed a single or multiple expressions, what does output always end with by default?

A newline.

How does top-down design work?

A problem is decomposed into smaller problems, which are gradually solved to produce a solution.

What statement describes what a semantic error is?

A semantic error occurs when an expression is syntactically correct, but the expression cannot be carried out.

In a conditional iteration loop, such as a while loop, what is a sentinel value?

A sentinel value is a special value provided by the user to terminate the loop.

What statement regarding the structure of strings is accurate?

A string is a sequence of zero or more characters.

What statement accurately describes the difference between a list and a tuple?

A tuple's contents cannot be changed.

____took the concept of a programmable computer a step further by designing a model of a machine that bore a striking resemblance to a modern general-purpose computer

Charles Babbage

What was the first PC-based operating system called?

Control Program for Microcomputers (CP/M)

Steve Jobs wrote the first Web server and Web browser software.

False

Text processing is by far the least common application of computing.

False

The + operator allows you to build a string by repeating another string a given number of times.

False

The cost of developing software is spread equally over the phases.

False

The design phase of the waterfall model is also called the coding phase.

False

The development of the transistor in the early 1960s allowed computer engineers to build ever smaller, faster, and less expensive computer hardware components.

False

The modulus operator has the highest precedence and is evaluated first.

False

The process of sending a result back to another part of the program is known as pushing a value.

False

When executing the print statement, Python first displays the value and then evaluates the expression.

False

When using a computer, human users primarily interact with the memory.

False

string is an example of a data type in Python.

False

When writing Python programs, you should use a .pyt extension.

False - When writing Python Programs, you should use the .py extension.

You are reviewing the code written by another programmer, and encounter a variable whose name is entirely in capital letters. What might you discern from this variable name?

The variable is a symbolic constant.

In evaluating a loop, you find the following statement: "value += 1". What happens to the value variable upon each iteration of the loop?

The variable is increased by 1 each iteration through the loop.

Given the following statement: "%4d" % var1, which of the following is accurate?

The variable var1 must be an integer value.

When a Python script is running as a standalone program, what will the __name__ variable be set to?

The variable will be set to "__main__".

By the mid 1980s, the Arpanet had grown into what we now call the Internet, connecting computers owned by large institutions, small organizations, and individuals all over the world.

True

Computer Scientists refer to the process of planning and organizing a program as software and development.

True

Computer science focuses on a broad set of interrelated ideas.

True

Each individual instruction in an algorithm is well defined.

True

Expressions provide an easy way to perform operations on data values to produce other data values.

True

Guido van Rossum invented the Python programming language in the early 1990s.

True

If Python expression is well formed, the interpreter translates it to an equivalent form in a low-level language.

True

In 1984, Apple Computer brought forth the Macintosh, the first successful mass-produced personal computer with a graphical user interface.

True

In Python, functions and other resources are coded in components called modules.

True

In general, a variable name must either begin with a letter or an underscore (_).

True

In the 1960s, batch processing sometimes caused a programmer to wait days for results, including error messages.

True

Magnetic storage media, such as tapes and hard disks, allow bit patterns to be stored as patterns on a magnetic field.

True

Modern software development is usually incremental and iterative.

True

Programs rarely work as they are hoped to the first they are run.

True

Real numbers, have infinite precision, which means that the digits in the fractional part can continue forever.

True

Testing is a deliberate process that requires some planning and discipline on the programmer's part.

True

The algorithms that describe information processing can also be represented as information.

True

The first electronic digital computers, sometimes called mainframe computers, consisted of vacuum tubes, wires, and plugs, and filled entire rooms.

True

The interpreter reads a Python expression or statement, also called the source code, and verifies that it is well formed.

True

The most important example of system software is a computer's operating system.

True

The part of a computer that is responsible for processing data is the CPU.

True

The remove file system function is included in the os.path module.

True

There is more to software development than writing code.

True

Variables receive their initial values and can be reset to new values with an assignment statement.

True

When the Python interpreter evaluates a literal, the value is simply that literal.

True

You can use parentheses to change the order of evaluation in an arithmetic expression.

True

In science or any other area of inquiry, a(n)____allows human beings to reduce complex ideas or entities to simpler ones

abstraction

When choosing an algorithm, faster run times can often be achieved at the expense of what other resource?

active memory

The sequence of steps that describes a computational process is called a(n)

algorithm

You are creating a Python script that will make use of user input contact names and their associated phone numbers. What would be ideal for storing and accessing these associated values?

dictionaries

What function can you call inside of IDLE to show the resources of the math module, once it has been imported?

dir(math)

What are the two different types of loops that are used within the Python language?

definite iteration, indefinite iteration

In order to change the print function to output on the same line as the previous one, without printing a newline, what expression can be added?

end = ""

The while loop is also known as what kind of a loop?

entry-control loop

The attributes of an object are represented as what type of variables?

instance variables

Python is a(n)____language

interpreted

What term describes a dictionary of functions keyed by command names?

jump table

The assignment of roles and responsibilities to different actors in a program is known as what type of design?

responsibility-driven design

What string method can you use to locate the lowest index in a string named s where substring "findme" is found?

s.find("findme")

What two methods can be used to return a copy of a string named s converted to all lowercase and all uppercase respectively?

s.lower(), s.upper()

In Python, what is the term that is used to describe the area of a program text in which an object name refers to a given value?

scope

Flash memory sticks are an example of____storage media

semiconductor

A flash memory stick is an example of what type of storage media?

semiconductor storage media

____is the set of algorithms, represented as programs in particular programming languages

software

For each call of a function, the Python virtual machine must allocate a small chunk of memory on the call stack, which is known by what term?

stack frame

What type of error is raised when the Python virtual machine runs out of memory resources to manage a process?

stack overflow error

The gradual process of developing functions to solve each subproblem in a top-down design is known as what process?

stepwise refinement

You are parsing a comma separated value string with Python. What method can you use to separate the values in each line and place them in a list?

string.split(',')

What is the name for a diagram that shows the relationships among a program's functions and the passage of data between them?

structure chart

What is NOT a Boolean or logical operator used in the Python language?

xor

In the modern world of computers, information is also commonly referred to as____

data

What comparison operator is used to test whether an expression does NOT equal another expression?

!=

What will be the return value of running the following function? chr(ord('T')+5)?

"Y"

What are the two different ways that default arguments can be provided to a function?

-By supplying arguments in which they occur in the function header. -By assigning values to the keys in the function header.

Which of the following literals would be considered a float type in Python?

3.14

What are two common methods by which functions serve as abstraction mechanisms?

-The elimination of redundant, or repetitious code. -The hiding of complicated processes.

Which of the following statements are accurate?

-When module variables are introduced in a program, they are immediately given a value. -Temporary values receive their values as soon as they are introduced.

What are the two different means by which a floating-point number can be written?

-scientific notation -decimal notation

What is the decimal number 98 in binary?

1100010

What is the value of the binary number 10010110 in base-10?

150

In the binary number system, each digit or bit has a positional value that is a power of what?

2

What is the total number of distinct values in the ASCII set?

256

Regarding class variables, what statement is accurate?

A class variable is visible to all instances of a class, and does not vary from instance to instance.

What does a block cipher utilize in order to change plaintext characters into two or more encrypted characters?

A mathematical structure known as an invertible matrix.

What term describes the process of substituting a simple process for a complex process in a program to make the program easier to understand and maintain?

Abstraction

What happens if you attempt to access a string using an index equal to the string's length?

An error will occur, indicating the index is out of range.

At what point in the interpretation of a Python program are syntax error messages generated?

Before execution of the program, when it is passed through the translator.

Of the techniques that can be used to determine the efficiency of an algorithm, which is based on a calculated average of average run time?

Benchmarking

How does the int function convert a float to an int?

By removing the fractional value of the number

You are running a Python script and suspect that the script has entered an infinite loop. What key combination can you use to halt the loop?

CTRL + c

The encryption method that replaces a character in a text with another character some given distance away in the alphabet from the original is known as what type of cipher?

Caesar cipher

In evaluating the precedence rules used by Python, what statement is accurate?

Exponentiation has the highest precedence

____was considered ideal for numerical and scientific applications

FORTRAN

1,500 is a valid integer literal in Python.

False

A program stored in computer memory must be represented in binary digits, which is also known as ASCII code.

False

An algorithm describes a process that may or may not halt after arriving at a solution to a problem.

False

Assuming that the value of x is 4, and the value of y is 6, what is the value of the following expression? (x - y)**2 > y

False

Exponentiation and assignment operations are left associative.

False

In Python % is the exponentiation operator.

False

In Python \b is an escape sequence that represents a horizontal tab.

False

In Python, a floating-point number must be written using scientific notation.

False

In Python, the programmer can force the output of a value by using the cout statement.

False

In the 1930s, the mathematician Blaise Pascal explored the theoretical foundations and limits of algorithms and computation.

False

In the early 1940s, computer scientists realized that a symbolic notation could be used instead of machine code, and the first assembly languages appeared.

False

In the maintenance phase if the waterfall model, the parts of a program are brought together into a smoothly functioning whole, usually not an easy task.

False

Informally, a computing agent is like a recipe.

False

Information is stored as patterns of bytes (1s and 0s).

False

Moore's Law states that the processing speed and storage capacity of hardware will increase and its cost will decrease by approximately a factor of 3 every 18 months.

False

Python includes many useful functions, which are organized in libraries of code called classes.

False

Python is a loosely typed programming language.

False

A modern____organizes the monitor screen around the metaphor of a desktop, with windows containing icons

GUI

What is the process in which the Python virtual machine recycles its storage known as?

Garbage collection

____developed a system of logic which consisted of a pair of values, TRUE and FALSE, and a set of three primitive operations on these values, AND, OR, and NOT

George Boole

What language, created by Tim Berners-Lee, allows browsers to structure the information to be displayed on Web pages?

HTML

Which of the following are examples of protocols that utilize encryption for data transfer?

HTTPS, FTPS

____developed a machine that automated data processing for the U.S. Census

Herman Hollerith

What is the name used for the integrated program development environment that comes with a Python installation?

IDLE

Where can the required arguments for a function be found?

In the function header.

What statement accurately describes the analysis phase of the waterfall model?

In this phase, the programmers determine what the program will do.

What processor was contained in the first mass-produced personal computer?

Intel 8080

In general terms, what does a selection statement do?

It allows a computer to make choices based on test conditions.

What is the lambda function in Python utilized for?

It allows for the creation of an anonymous function, which contains the names of its arguments and a single expression.

What is the __str__ method used for?

It builds and returns a string representation of an object's state.

What is a count controlled loop?

It is a loop that counts through a range of numbers to control when the loop ends.

In programming, what is a prototype?

It is a rough draft of a program.

What is a one-way selection statement in the context of Python?

It is a single if statement without a corresponding else statement used to test a condition and run statements, then proceed to the next statement.

How is data stored within a computer's memory?

It is stored as binary data.

In Python, functions are treated as first-class data objects. What does this mean?

It means that functions can be assigned to variables, passed as arguments to other functions, returned as values, and stored in data structures.

What special character does the '\b' escape sequence generate?

It produces a backspace special character, which performs the same function as the backspace key.

What does the os module function remove do when called?

It removes a given file that is passed to it.

In Python, what does the "%" operator do in the expression 6 % 4?

It returns a remainder or modulus

What is the purpose of a higher-order function?

It separates the task of transforming data values from the logic of accumulating the results.

Early in the nineteenth century, ____designed and constructed a machine that automated the process of weaving

Joseph Jacquard

In its early days, ____was primarily used for lab experiments in an area of research known as artificial intelligence

LISP

What is NOT one of the initial four locations connected by the ARPANET in the 1970s?

Massachusetts Institute of Technology

Of the numerous sorting algorithms, what algorithm employs a recursive, divide-and-conquer strategy that breaks a list in two at the middle point and recursively sorts the lists?

Merge sort

What happens when a function tries to assign or change a value of a variable that has been defined at the module level?

Python creates a temporary variable with the same name, and the value of that variable exists only within the scope of the function.

To quit the Python shell, you can either select the window's close box or press the____key combination

ctrlD

What component of Python is responsible for the execution of Python byte code?

Python virtual machine (PVM)

The primary memory of a computer is also sometimes internal or____

RAM

Ancient mathematicians developed the first algorithms.

True

The decimal number system, which utilizes the numbers 0-9, is also known as what number system?

The base-10 numbering system

What is the call stack used for in the Python virtual machine?

The call stack is an area of reserved memory used to store chunks of memory related to functions.

What statement regarding precedence of operators is accurate?

The comparison operators (==, !=, <, >, <=, >=) are higher in precedence than the assignment operator (=).

When you launch Python, what file system path does it start with?

The current working directory.

You are running a Python script that is supposed to write data to an open file, but discover that the file contents are not updating even after the script finishes. What is most likely the issue?

The file was not closed using the close() method.

You are running a Python script that is supposed to write data to an open file, but discover that the file contents are being erased each time the script runs. What is most likely the issue?

The file was opened using a mode string other than 'a'

What does a mode string of 'r' indicate when opening a file in Python?

The file will be opened for read access.

What must be done in order to concatenate a string and a float object?

The float object must be converted to a string via the str() function.

What part of the loop comprises the statements to be executed?

The loop body.

In the waterfall diagram model, what is the most expensive part of software development?

The maintenance phase

What effect does the following print statement have? print("Hello"*5)

The print statement will produce "HelloHelloHelloHelloHello".

What statement accurately reflects the difference between the quotient operator and the division operator?

The quotient operator produces an integer, while the division operator produces a float.

What makes up a Python program's namespace?

The set of all its variables and their values.

What problem was the Atanasoff-Berry Computer designed to solve?

The solving of systems of simultaneous linear equations.

What would be the output if you were to print the variable named value as declared by this statement: value = "2" + "2"?

The string "22".

What can often provide you with a pattern for designing the structure of a program?

The structure of the problem you're attempting to solve.

While viewing a screen displaying an active IDLE session, what does green text mean?

The text represents a string.

When using the range function, what effect does the specification of a third argument have?

The third argument specifies a step value to be used in the range.

What is the largest value of an int data type in the Python programming language?

The value is limited only by the memory of the host computer

When reading the syntax for the print command, what does the ellipsis between expressions indicate?

They indicate that you could include multiple expressions after the first one.

Who is credited as having created the World Wide Web in 1992?

Tim Berners-Lee

When attempting to produce a correct program, what is the point of developing a test suite?

To provide a small set of inputs as a test to verify that a program will be correct for all inputs.

A programmer typically starts by writing high-level language statements in a text editor.

True

A semantic error is detected when the action which an expression describes cannot be carried out even though that expression is syntactically correct.

True

A variable associates a name with a value making it easy to remember and use the value later in the program.

True

An algorithm describes a process that ends with a solution to a problem.

True

An algorithm solves a general class of problems.

True

An important part of any operating system is its file system, which allows human users to organize their data and programs in permanent storage.

True

In Python, when does an object reach the end of its life?

When it can no longer be referred to by the program that created it.

In the early 1980s, a college dropout name Bill Gates and his partner Paul Allen built their own operation system software, which they called____

Windows

What scenario would it make logical sense to use a multi-way selection statement for?

You need to convert numeric grades to letter grades.

Functions that are always available in Python come from what module?

__builtin__

The use of +=, -=, and *= are all examples of what type of operators?

augmented assignment operators

In a recursive function, what is used to determine whether to stop or to continue with another recursive step?

base case

Inside of a loop, after a termination condition has been met, what statement can be used to cause an exit from the loop and execute the remainder of the script?

break

When a Python interpreter runs a script, what is the script translated into?

byte code

When a sender of information encrypts that information, what is the resulting text known as?

cipher text

In Python, you can write a print statement that includes two or more expressions separated by____

commas

The action described by the instruction in an algorithm can be performed effectively or be executed by a____

computing agent

What type of processing occurs when processes run for a slice of time, then yield access to the CPU to another process, cycling through processes repeatedly?

concurrent processing

Your script is parsing filenames and is creating a count of how many files per file extension type exist within a directory. What slice could you use to extract the file extension substring, assuming the extensions are three letters only?

filename[-3:]

In what higher-order function do you apply a predicate to each value within a list, and if the predicate returns true, the value is added to an object?

filtering

An algorithm consists of a(n)____ number of instructions

finite

In python, what data type is used to represent real numbers between -10^308 and 10^308 with 16 digits of precision?

float

A sentinel value is a special value provided by the user to terminate the loop.

four spaces

You are working on a Python script that relies heavily on the cos and sin functions of the math module. As these are the only functions you require, what should you do to import only these functions, rather than the whole math module?

from math import cos, sin

What os module function should you use to get the path of the current working directory?

getcwd()

____consists of the physical devices required to execute algorithms

hardware

____programming languages resemble English and allow the author to express algorithms in a form that other people can understand

high-level

In a computer, the____devices include a keyboard, mouse, and microphone

input

In carrying out the instructions of any algorithm, the computing agent starts with some given information known as____

input

Which of the following is NOT a valid name that can be used for a variable?

lending

A____takes a set of machine language instructions as input and loads them into the appropriate memory locations

loader

An off-by-one error is an example of what type of error in programming?

logic error

Tapes and hard disks are an example of____storage media

magnetic

What higher-order function process applies a function to each value in a sequence and returns a new sequence of the results?

mapping

What os.path module function can you use to convert a path to a pathname appropriate for the current file system?

normcase(path)

You are attempting to open a file containing a list of integer numbers, each on a separate line, and read them into Python as int types. What statement could you use to do this, assuming each line is represented by the line variable in a continuous loop?

num = int(line.strip())

What higher-order function takes a list of values and repeatedly applies a function to accumulate a single data value?

reducing

The process of hiding a complex process by developing a mechanism to simplify or hide that process is known by what term?

obfuscation techniques

CDs and DVDs are an example of____storage media

optical

Which of the following functions and expressions will convert the ASCII character "Z" to its numeric equivalent ASCII code?

ord('Z')

What specific Python module can you use to determine the file size in bytes of a given file?

os.path

In carrying out the instructions of any algorithm, the computing agent transforms some given information according to well-defined rules and produces new information known as____

output

Computers can communicate with the external world through various____that connect them to networks and to other devices such as handheld music players and digital cameras

ports

What statement should you use to print the value of total with a precision of 5 digits?

print("The total is %0.5f" % total)

What print statement will output a single '\' character?

print('\\')

The CPU, which is also sometimes called a____, consists of electronic switches arranged to perform simple logical, arithmetic, and control operations

processor

When using IDLE for Python programming, what color is used to distinguish built-in function names?

purple

What function call will generate a random number in the range of 1 through 6 using the random module?

random.randint(1, 6)

What file access method can be used to read a single line of input and return the line as a string, including the newline character?

readline

The Fibonacci sequence is a series of values that can be easily calculated with what kind of function?

recursive function

The Python interpreter rejects any statement that does not adhere to the grammar rules, or____

syntax

What technology replaced the vacuum tube as the mechanism for implementing electronic switches in computer hardware?

transistor

What program is used by a programmer to convert high-level code into executable code?

translator


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

Chapter 2: How we see the Invisible World

View Set

History 122 Chapter 31-Societies at Crossroads

View Set

Chapter 11 173 terms jasminefevan

View Set

AP MarcoEconomic Unit 1 Test Review

View Set

NUTRITION QUIZ 1 (Chapters 1, 2, 3, 4, 5, 6, 7, 8). NURS 220

View Set

Python: Math and Logic Operators

View Set

Introduction to Tax Law (Quiz 1)

View Set

OB Chapter 14-Nursing Management During Labor and Birth

View Set