final exam

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

Which of the following is the correct if clause to determine whether choice is anything other than 10?

if choice != 10:

Programs are commonly referred to as

software

def pass_it(x, y): z = x + ", " + y return(z)name2 = "Tony"name1 = "Gaddis"fullname = pass_it(name1, name2)print(fullname)

Gaddis, Tony

Which logical operators perform short-circuit evaluation?

or, and

A(n) ________ is a variable that receives an argument that is passed into a function.

parameter

Which of the following will display 20%?

print(format(0.2, '.0%')) <enter>

which of the following will display 20%?

print(format(0.2, '.0%')) <enter>

What is the informal language, used by programmers use to create models of programs, that has no syntax rules and is not meant to be compiled or executed?

pseudocode

In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function.

return

The ________ of a local variable is the function in which that variable is created.

scope

Which method could be used to convert a numeric value to a string?

str

Which type of error prevents the program from running?

syntax

The ________ design technique can be used to break down an algorithm into functions.

top-down

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total?

total += number total = number

What will be displayed after the following code is executed?for num in range(0, 20, 5):num += numprint(num)

30

If 3 is entered as the number, what will the output be? total = 1.0number = float(input('Enter a number: ')) for counter in range(10): total += number print ('The total is', total)

31

What will be displayed after the following code is executed?total = 0for count in range(1,4):total += countprint(total)

6

After the execution of the following statement, the variable price will reference the value ________.price = int(68.549)

68

In Python the ________ symbol is used as the equality operator.

==

student = 1while student <= 3: total = 0 for score in range(1, 4): score = int(input("Enter test score: ")) total += score average = total/3 print("Student ", student, "average: ", average) student += 1

It accepts 3 test scores for each of 3 students and outputs the average for each student. It accepts 4 test scores for 2 students, then averages and outputs all the scores.

What type of volatile memory is usually used only for temporary storage while running a program?

RAM

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?x < y or z > x

True

A Boolean variable can reference one of two values which are

True or False yes or no

The line continuation character is a

\

What is a group of statements that exists within a program for the purpose of performing a specific task?

a function

What symbol is used to mark the beginning and end of a string?

a quote mark ( "

What symbol is used to mark the beginning and end of a string?

a quote mark (")

The smallest storage location in a computer's memory is known as a

bit

What type of loop structure repeats the code a specific number of times?

count-controlled loop, condition-controlled loop number-controlled loop

What will be displayed after the following code is executed?count = 4while count < 12:print("counting")count = count + 2

counting counting, counting, counting

Given that the customer file references a file object, and the file was opened using the 'w' mode specifier, how would you write the string 'Mary Smith' to the file?

customer.write('Mary Smith')

The process known as the ________ cycle is used by the CPU to execute instructions in a program.

fetch-decode-execute

A single piece of data within a record is called a

field

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) ________ data type.sold = 256.752

float

A(n) ________ is a diagram that graphically depicts the steps that take place in a program?

flow chart

A ________ variable is accessible to all the functions in a program file.

global

The first line in a function definition is known as the function

header

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?

if y >= 10 and y <= 50: if y >= 10 or y <= 50:

if the first amount is 7 and the second amount is 36, what will be the output of the following code: if amount1 > 10 and amount2 < 100: if amount1 > amount2: print (amount1) elif amount2 > amount1: print (amount2) else: print('Both values are the same.')

nothing

Which of the following will assign a random integer in the range of 1 through 50 to the variable number?

number = random.randint(1, 50) number = random(range(1, 50)) random(1, 50) = number

When using the ________ logical operator, one or both of the subexpressions must be true for the compound expression to be true.

or

Which mode specifier will open a file but not let you change the file or write to it?

'r'

The ________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

**

Which mathematical operator is used to raise 5 to the second power in Python?

**

What is the output of the following command, given that value1 = 2.0 and value2 = 12?print(value1 * value2)

24.0

What will display after the following code is executed?def main():print("The answer is", magic(5))def magic(num):answer = num + 2 * 10return answermain()

25

What is the largest value that can be stored in one byte?

255

A variable used to keep a running total is called a(n)

accumulator

What are the values that the variable num contains through the iterations of the following for loop?for num in range(4):

0, 1, 2, 3

How many times will this loop iterate? total = 0.0 for counter in range(10): number = float(input('Enter a number: ')) total += number print ('The total is', total)

10

What will be displayed after the following code is executed? def pass_it(x, y):z = x*yresult = get_result(z)return(result)def get_result(number):z = number + 2return(z)num1 = 3num2 = 4answer = pass_it(num1, num2)print(answer)

14

What is the decimal value of the following binary number?10011101

157

What are the values that the variable num contains through the iterations of the following for loop?for num in range(2, 9, 2):

2, 4, 6, 8

The ________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory.

ASCII

Which language is referred to as a low-level language?

Assembly language

A(n) ________ is any piece of data that is passed into a function when the function is called.

argument

Which computer language uses short words known as mnemonics for writing programs?

assembly

Which of the following if-else statement assigns 3 to the variable b if the variable a is greater than 25. Otherwise it will assign 36 to variable b.

b = 36 Answers: if a > 25: b = 3 else: b = 36

The Python turtle is initially positioned in the ________ of a graphics window and it first appears, by default, to be heading ________.

center, east

A(n) ________ structure is a logical design that controls the order in which a set of statements execute.

control

Which of the following statements causes the interpreter to load the contents of the random module into memory?

import random

To use Python's turtle graphics, you must include which of the following statements in your program?

import turtle

Where does a computer store a program and the data that the program is working with while the program is running?

in main memory

Which of the following is the correct way to open a file named users.txt in 'r' mode?

infile = open('users.txt', 'r')

The ________ built-in function is used to read a number that has been typed on the keyboard.

input

The ________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input()

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called

list

A ________ variable is created inside a function.

local

The following is an example of an instruction written in which computer language?10110000

machine language


Ensembles d'études connexes

Chapters 16, 17, 18, 19 Vocabulary

View Set

MGT 420 Topic 1 Adaptive Practice

View Set

Hormones for the Final Exam - Melatonin

View Set

predator/prey/carnivore/herbivore/omnivore

View Set

Bio Med Ethics: Kant and Deontological Ethics

View Set