Programming Fundamentals

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

str

A Python data type that holds a string of characters

int

A Python data type that holds positive and negative whole numbers

float

A Python data type which stores floating-point numbers

expression

A combination of variables, operators, and values that represents a single result value

stack diagram

A graphical representation of functions, their variables, and the values to which they refer

variable name

A name given to a variable

variable

A name that refers to a value

value

A number or string (or other things to be named later) that can be stored in a variable or computed in an expression

source code

A program in a high-level language before being compiled

script

A program stored in a file (usually one that will be interpreted)

high-level language

A programming language like Python that is designed to be easy for humans to read and write

low-level language

A programming language that is designed to be easy for a computer to execute; also called machine language or assembly language

portability

A property of a program that can run on more than one kind of computer

keyword

A reserved word that is used by the compiler to parse programs

data type

A set of values

operator

A special symbol that represents a simple computation like addition, multiplication, or string concatenation

assignment statement

A statement that assigns a value to a name (variable)

function call

A statement that executes a function. It consists of the name of the function followed by a list of arguments enclosed in parentheses

local variable

A variable defined inside a function that can only be used inside its function

semantic error

An error in a program that makes it do something other than what the programmer intended

syntax error

An error in a program that makes it impossible to parse — and therefore impossible to interpret

runtime error

An error that does not occur until the program has started to execute but that prevents the program from continuing

print statement

An instruction that causes the Python interpreter to display a value on the screen

statement

An instruction that the Python interpreter can execute

python shell

An interactive user interface to the Python interpreter

byte code

An intermediate language between source code and object code

integer division

An operation that divides one integer by another and yields an integer

executable

Another name for object code that is ready to be executed

formal language

Any one of the languages that people have designed for specific purposes, such as representing mathematical ideas or computer programs; all programming languages are this kind of languages

natural language

Any one of the languages that people speak that evolved naturally

An advantage of Pseudo code is that it is a visual technique.

False

Fortran language was designed to process business transactions

False

One of the advantages of a function is that it allows the programmer to alter the flow of execution in the program.

False

One of the advantages of flowcharts is that it is hard to modify.

False

Perl, Python, and PHP are all compiled languages

False

Portability means the program is written in small chunks of code.

False

Pseudo code should contain the exact same statements as the programming language that will be used.

False

The C language was developed at Bell Labs with the objective of being the first object oriented language

False

The graphical representation of a stack of functions, their variables, and the values to which they refer is called a traceback?

False

The use of arrows in flowcharts is optional because the flow direction is obvious.

False

Variable names are not case sensitive.

False

comment

Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program

token

One of the basic elements of the syntactic structure of a program, analogous to a word in a natural language

operand

One of the values on which an operator operates

composition

The ability to combine simple expressions and statements into compound statements and expressions in order to represent complex computations concisely

header

The first part of a compound statement, begins with a keyword and ends with a colon

flow of execution

The order in which statements are executed during a program run

object code

The output of the compiler after it translates the program

debugging

The process of finding and removing any of the three kinds of programming errors

problem solving

The process of formulating a problem, finding a solution, and expressing the solution

rules of precedence

The set of rules governing the order in which expressions involving multiple operators and operands are evaluated

parse

To examine a program and analyse the syntactic structure

interpret

To execute a program in a high-level language by translating it one line at a time

concatenate

To join two strings end-to-end

evaluate

To simplify an expression by performing the operations in order to yield a single value

compile

To translate a program written in a high-level language into a low-level language all at once, in preparation for later execution

A flowchart with more than 15 symbols is considered poor form.

True

A local variable is a variable defined inside a function that can only be used inside its function.

True

A program is a sequence of instructions that specifies how to perform a computation.

True

A script usually contains a sequence of statements. If there is more than one statement, the results appear one at a time as the statements execute.

True

A stack diagram shows the value of each variable and the function to which each variable belongs.

True

An advantage of Pseudo code is that it requires no special tools and can easily be written on a word processor.

True

An expression is a combination of values, variables, and operators. If you type an expression on the command line, the interpreter evaluates it and displays the result.

True

As programs get bigger and more complicated, they get more difficult to read. This is why programmers should use Comments in their code.

True

Every flowchart must have a START and STOP symbol.

True

In a script, an expression all by itself is a legal statement, but it doesn't do anything.

True

One of the advantages of pseudo code is that it implements structured concepts well.

True

Programmers generally choose names for their variables that are meaningful and document what the variable is used for.

True

Pseudo code is a newer tool and has features that make it more reflective of the structured concepts.

True

The COBOL language was designed to solve business problems and was adapted to processing business transactions

True

The acronym PEMDAS is a useful way to remember the order of operations in Python.

True

algorithm

a general process for solving a category of problems

program

a sequence of instructions that specifies to a computer actions and computations to be performed

What will the output of this program be when it is executed? def test_function( length, width, height): print ("the area of the box is ", length*width*height) return length*width*height l = 12.5 w = 5 h = 2 test_function(l, w, h) print ("The area of the box is ", length*width*height) a. A NameError because a variable not defined b. The area of the box is 125.0 c. The area of the box is 0 d. A SyntaxError due to illegal function call

a. A NameError because a variable not defined

The concept of a computer 'bug' was first attributed to ______ who found a moth stuck in a relay that caused a failure in a computer at Harvard University. The term 'debugging' has since come to mean correcting errors in a computer or computer program. a. Grace Murray Hopper b. John von Neumann c. Charles Babbage d. Konrad Zuse

a. Grace Murray Hopper

bug

an error in a program

exception

another name for a runtime error

What output will the following python command produce: >>> percentage = ( 60 * 100) // 55 >>> print (percentage) a. Percentage b. 109 c. 109. 0909090909091 d. 109.0

b. 109

What output will the following python commands produce: >>> print (2*3-1) a. 6 b. 5 c. 4 d. 3

b. 5

What output will the following python commands produce: >>> print ((1+1)**(5-2)) a. 16 b. 8 c. 4 d. 2

b. 8

What output will the following Python script produce? def function2(param): print (param, param) def function1(part1, part2): cat = part1 + part2 function2(cat) chant1 = "See You " chant2 = "See Me " function1(chant1, chant2) a. See You See Me b. See You See Me See You See Me c. See Me See Me See You See You d. None it would generate an error

b. See You See Me See You See Me

What will the output of this python program be? def test_function( length, width, height): print ("the area of the box is ",length*width*height) return length*width*height l = 12.5 w = 5 h = 2 test_function(l, w, h) a. The area of the box is 125 b. The area of the box is 125.0 c. The area of the box is 120 d. 125.0

b. The area of the box is 125.0

The three kinds or errors that can occur in a program are_______________ a. algorithms, debugging, iterations b. syntax, runtime, semantic c. looping, spelling, conditional d. scripting, command line, interpreter

b. syntax, runtime, semantic

During the 1990's, a major influence on programming languages was____________________ a. consolidation, modules performance b. the internet c. fundamental paradigms d. formula translation

b. the Internet

What output will the following python command produce: >>> print (1,000,000) a. 1,000 b. 1,000,000 c. 1 0 0 d. Error invalid type

c. 1 0 0

What output will the following python command produce: percentage = ( 60.0 * 100.0 ) / 55.0 print (percentage) a. Percentage b. 109 c. 109. 0909090909091 d. 109.0

c. 109.0909090909091

What output will the following python commands produce: >>> print (2 * (3-1)) a. 6 b. 5 c. 4 d. 3

c. 4

Which of the following is NOT one of the computer languages developed in the 1950s a. COBOL b. Fortran c. BASIC (Beginners All Purpose Symbolic Instruction Code) d. LISP

c. BASIC

A popular computer language developed by Dennis Ritchie and Ken Thompson at Bell Labs in the 70's is: a. APL b. BASIC c. C d. PL/1

c. C

The BASIC language was developed by John G. Kemeny at which school: a. Harvard University b. Stanford University c. Dartmouth College d. Carnegie Mellon University

c. Dartmouth College

Which of the following is NOT a programming language. a. Java b. C c. Kuntz d. Ruby

c. Kuntz

Using keywords for variable names will result in a ________________ a. Runtime error b. Compile error c. Syntax error d. Semantic error

c. Syntax error

Python is considered to be _______________ a. a database language b. a formula translation language c. an internet language d. a business oriented language

c. an internet language

What output will the following python commands produce: >>> n = 17 >>> print (n) a. (n) b. 17.0 c. n d. 17

d. 17

What will the output of the following program be? i=0 while (i < max(1, 22-4*5, 3*5-3*4, 2**2)): i+= 1 print (i) a. 0 b. 5 c. 3 d. 4

d. 4

Which of the following is NOT one of the rules for pseudo code: a. Indent to show hierarchy b. Keep statements language independent c. Write only one statement per line d. Capitalize every word

d. Capitalize every word

What does the import statement in the following script do? import StringIO output = StringIO.StringIO() output.write('First line.\n') output.close() a. It imports data into the script b. It changes the format of the string in the script c. It opens a file for StringIO functions to read d. It includes a Python module called StringIO into the script

d. It includes a Python module called StringIO into the script

What will the output of the following code be? def recursive( depth ): depth+=1 while (depth < 5): ret = recursive(depth) return depth ret = recursive( 0 ) print ("the recursive depth is ", ret) a. The recursive depth is 5 b. The recursive depth is 4 c. Error due to depth of recursive calls d. None

d. None

semantics

the meaning of a program

syntax

the structure of a program


Kaugnay na mga set ng pag-aaral

Team Dynamics and Cohesion CHAPTER 9

View Set

Ch 25 Long-term Complications of Diabetes

View Set

Unit 2 - Languages with Special Roles: National and Official Languages

View Set

1066 Non-Invasive Exam Reading Quiz

View Set

CH15: Income, Wealth and Poverty

View Set

COM 275 Exam 1 Practice Questions

View Set

chapter 10 (test2) study questions

View Set