A(n) _______ is the part of a program in which a variable may be accessed.
a. declaration space
b. area of visibility
c. scope
d. mode
Answer: scope
a. declaration space
b. area of visibility
c. scope
d. mode
Answer: scope
a. global variable
b. local variable
c. hidden variable
d. none of the above; you cannot create a variable inside a function
Answer: local variable
a. flowchart
b. function relationship chart
c. symbol chart
d. hierarchy chart
Answer: hierarchy chart
a. top-down design
b. code simplification
c. code refactoring
d. hierarchical subtasking
Answer: top-down design
a. define
b. call
c. import
d. export
Answer: call
a. body
b. introduction
c. initialization
d. header
Answer: header
a. code reuse
b. divide and conquer
c. debugging
d. facilitation of teamwork
Answer: code reuse
a. block
b. parameter
c. function
d. expression
Answer: function
Answer: true
Answer: true
Answer: false
Answer: false
Answer: second
Answer: polymorphism
Answer: self parameter
Answer: inheritance
Answer: label
Answer: third
Answer: setters
Answer: Inheritance
Answer: false
Answer: object
Answer: __init__
Answer: GUI programs
Answer: GUI
Answer: false
Answer: false
Answer: superclass
Answer: attributes and methods
Answer: true
Answer: canvas
Answer: message
Answer: instance
Answer: true
Answer: true
Answer: scale
Answer: getters
Answer: false
Answer: is a
Answer: Dictionary is not indexed by number
special = '1357 Country Ln.'
s_string = special[ :4]
Answer: '1357'
Answer: update
i = 3
pattern = 'z' (5 i)
Answer: 'zzzzzzzzzzzzzzz'
Answer: { 1 : 'January', 2 : 'February', 3 : 'March' }
list_string = '03/07/2008'
list_string = list_string.split('/')
Answer: ['03', '07', '2008']
Answer: find(substring)
list = [1, 2, 3, 4]
list[3] = 10
Answer: [1, 2, 3, 10]
special = '0123456789'
even = special[0:10:2]
Answer: '02468'
Answer: in
Answer: once a tuple is created, it cannot be changed
Answer: nested list
string = 'Hello'
string += ' world'
Answer: 'Hello world'
Answer: list
Answer: len
Answer: 0 through 7
phones = {'John': '555555', 'Julie': '7777777'}
phones['John'] = '1234567'
{'John': '1234567', 'Julie' : '7777777'}
special = '1357 Country Ln.'
s_string = special[4: ]
Answer: 'Country Ln.'
Answer: false
Answer: pickling
Answer: del statement
Answer: elements
list= [1, 2]
list = list * 3
Answer: [1, 2, 1, 2, 1, 2]
Answer: false
Answer: false
Answer: insert
relationships['jimmy']
Jimmy and jimmy are different
What is the value of the variable string after the execution of the following code?
myString = 'abcd'
myString = myString.upper()
Answer: 'ABCD'
list1 = [1, 2, 3]
list2 = []
for element in list1:
list2.append(element)
list1 = [4, 5, 6]
Answer: [1, 2, 3]
ages = {'Aaron': 6, 'Kelly': 3, 'Abigail': 1}
value = ages['Brianna']
Answer: KeyError
Answer: false
Answer: +
Answer: tuple
Answer: true
list1 = [1, 2, 3]
list2 = list1
list1 = [4, 5, 6]
Answer: [1,2,3]
Answer: pop
Answer: key
Answer: [0, 2, 4, 6, 8]
Answer: del
Answer: try/except statement
Answer: true
Answer: The function get_num() is expected to return a value each for num1 and num2.
Answer: function
Answer: true
Answer: true
Answer: true
Answer: global
Answer: argument
Answer: the number of times the function calls itself
Answer: true
Answer: true
Answer: header
Answer: calls itself to solve the smaller problem
Answer: block
Answer: modules
Answer: math
Answer: false
Answer: a function that will return a value back to the part of the program that called it
Answer: True
def magic(num):
return num + 2 * 10
Answer: 25
Answer: false
Answer: customer.write('Mary Smith')
Answer: read
Answer: parameter
Answer: A random integer from 5 to 15, multiplied by 2, assigned to the variable x
Answer: true
Answer: false
Answer: return
Answer: global
Answer: global
Answer: local
Answer: false
Answer: interpreter
Answer: standard
Answer: True
Answer: 'w'
Answer: scope
Answer: True
Answer: True
for num in range(4):
for num in range(1,5):
Answer: True
Answer: False
Answer: True
Answer: True
Answer: True
Answer: <=
Answer: True
Answer: repitition
Answer: False
Answer: False
Answer:
print('The path is D:\\sample\\test.')
The path is D:\sample\test
Answer: psuedocode
Answer: False
Answer: ==
Answer: False
Answer: accumulator
Answer: True
Answer: True
Answer: condition-controlled loop
Answer: False
Answer: count-controlled loop
Answer: 2,4,6,8
Answer: True
Answer: True
Answer:
price = int(68.549)
68
Answer: True
Answer: !=
Answer:
sold = 256.752
Float
Answer: True
Answer: flowchart
Answer: False
Answer: True
Answer: true or false
Answer:
24.0
Answer: end
Answer: True
Answer: True
Answer: If parts of the duplicated code have to be corrected, the correction has to be made many times.
Answer: When keep_on_going refers to a value equal to 999
Answer: x is less than or equal to y
For j=1 To 5 Step 2
Display j
End For
Answer: Three
Answer: pretest
Answer: Do-Until
Answer: count
Answer: accumulator
Answer: iteration
Set k=1
While k>5
Display k
End While
Answer: no iterations
Answer: pretest
Set k=1
While k<=5
Display k
End While
Answer: Infinite
Answer: Condition-controlled
Answer:
For k=7 to maxValue
Count-Controlled
Answer: While and Do-While
Answer: Repetition
Answer: Body of the loop
Answer: infinite
Answer: Three
Answer: For
Answer: For
Answer: posttest
Answer: Do-While and Do-Unit
Answer: Sentinel
Answer: sentinel
Answer: posttest
Set k=1
Do
Display k
Set k=k+1
Until k>1
Answer: One
Answer: condition
Answer: true
Answer: false
Answer: true
Answer: true
Answer: True
Answer: false
Answer: false
Answer: true
Answer: True
Answer: False
Answer: ^
Answer: &
Answer: -
Answer: |
Answer: remove
Answer: discard
Answer: update
Answer: add
Answer: len()
Answer: items()
Answer: get()
Answer: pop()
Answer: popitem()
Answer: {}
Answer: len()
Answer: del
Answer: in
def magic(num):
return num + 2 * 10
25
Answer: Float
Answer: Math
Answer: False
Answer: True
Answer: standard
Answer: True
Answer: The function get_num() is expected to return a value each for num1 and num2.
Answer: A random integer from 5 to 15, multiplied by 2, assigned to the variable x
Answer: interpreter
Answer: Modules
Answer: True
Answer: return
Answer: if-elif-else
Answer: number = random.randint(1, 50)
Answer: Floor
Answer: Boolean
Answer: Import random
Answer: a function that will return a value back to the part of the program that called it
Answer: False
Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows:
f = p * (1 + i)^t
• f is the future value of the account after the specified time period.
• p is the present value of the account.
• i is the monthly interest rate.
• t is the number of months.
p=float(input("Enter current bank balance:"))
i=float(input("Enter interest rate:"))
t=float(input("Enter the amount of time that passes:"))
print((p ((1+i)*t)))
A prime number is a number that is only evenly divisble by itself and 1. For example, the number 5 is prime because it can only be evenlly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 2 and 3.
n=int(input("Enter an integer:"))
def is_prime(n):
if n<2:
return False
elif n==2:
return True
else:
i=2
while i<n:
if((n%i)==0):
return False
elif (n==27):
return False
else:
i+=1
return True
print(is_prime(n))
Assume that max2 is a function that expects two int parameters and returns the value of the larger one.
Also assume that four variables , population1, population2, population3, and population4 have already been defined and associated with int values.
max(max(population1, population2), max(population3, population4))
max is a function that expects two int parameters and returns the value of the larger one.
Two variables , population1 and population2, have already been defined and associated with int values.
max(population1,population2)
def min(int1,int2):
if int1<int2:
return int1
elif int2<int1:
return int2
else:
return int1 or int2
def isSenior(int):
if int>=65:
return True
else:
return False
def signOf(int):
if int>0:
return 1
elif int==0:
return 0
else:
return -1
def absoluteValue(int):
return abs(int)
def powerTo (double,int):
if int>=0:
return double**int
else:
return 0
def oneLess(int):
return int-1
def add(int1,int2):
return int1+int2
i=2
k=0
sum=0
while(sum+i<=n):
if n==20:
k=3
elif(is_prime(i)):
sum += i
k += 1
i += 1
def largest(num1,num2,num3):
max(num1,num2,num3)
def add(int1,int2):
return int1+int2
def square(int):
return int**2
Given that add, a function that expects two int parameters and returns their sum, and given that two variables , euro_sales and asia_sales, have already been defined:
Answer: eurasia_sales =add(euro_sales,asia_sales)
def printGrade(grade):
print("Grade:",grade)
Answer: print_larger(sales1, sales2);
Answer: send_two(15.955,133);
Suppose a variable called x refers to an int. Pass this variable as an argument to send_variable .
send_variable(x);
send_number(5)
def printDottedLine():
print(".....")
Answer: send_signal()