C173 Scripting and Programming Foundations| Questions with Complete Solutions 100%
Solved| Grade A+
Which change would correct the following algorithm so that it will identify the maximum
number from a list with values 2,7,8,3,9,1
max = 0
for each value
if value > max
max = value
else
max = 0 * Remove the clause
What is algorithm time efficiency? The number of calculations required to solve a problem
function myNewFunction(integer x)
z=x-3
returns integer y
What is the parameter? integer x
A function's parameter is the information it needs to execute. This function needs and integer
that it will call x in order to complete.
What happens if you define a function but do not call it? Nothing. The code will simply
remain in memory but will not execute
Using the following function, which portion is the function declaration?
function myFunction(integer b)
a=b-3
returns integer a + b
myFunction(6) function myFunction(integer b)
,Using the following function, which portion calls the function?
function myFunction(integer b)
a=b-3
returns integer a + b
myFunction(6) myFunction(6)
Your user needs to enter a number into the program that will be used throughout its execution.
Before the user enters a number, which loop type can determine how many times the loop will
run? * For
Which loop types are best suited to continually check a test expression? while and do-while
What is the purpose of an "if" statement? To control what code executes based on the
result of a test expression
How many times can you call a function to run? as many times as you want
Fill in the blank so that the loop will iterate 10 times.
for i = 1; _________; i = i + 1; // Loop statements i <= 10
What is put to output by the following pseudocode?
x=4
while x >= 0
Put x to output
x=x-2 420
What is put to output by the following pseudocode?
,x=6
while x > 0
Put x to output
Put " " to output
x=x-2 642
How many times does this loop run?
a=8
b=4
while a % b == 0:
Put a to output
b=b+2 1
David is creating a grade book program for to keep track of his student's scores in a
programming course. This grade book will contain the students' names, email addresses, and
scores on each task.
Which control structure is best to look at the individual grades of each student for Task 1?
Grades are known For loop
Which control structure is best to send continual reminders to submit the upcoming
assignment and ensure that each student receives it at least once? do-while loop
Which control structure is best to assign extra credit work to each student scoring less than 75
on Task 2? if/else statement
Variable declaration Declares a new variable, specifying the variable's name and type
What is a variable? A name that can hold a value. Might be named x. Then, x = 7 assigns x
with 7, which remains in x while the program runs, until x is assigned again.
, Assignment Statement Assigns the variable on the left-side of the = with the current value of
the right-side expression
Expression A mathematical phrase that contains operations, numbers, and/or variables.
numApples is initially 5. What is numApples after:
numApples = numApples + 3; 8
Is the following statement valid?
x+y =y+x Invalid. In programming, the left side of = must be a variable, which will be
assigned with the right side's value. Thus, having x + y on the left side doesn't make sense.
Is the following assignment statement valid?
x+1=3 Valid. The left side must be a variable, not an expression like x + 1. In programming,
= does not mean equal. = means assign the left-side variable with the right-side's value. Thus,
the left side MUST be a variable.
x=9
y=x+1
What is y? 10
What does = mean? Assignment
What is the value of x?
x=2
y=3
x=x*y
Solved| Grade A+
Which change would correct the following algorithm so that it will identify the maximum
number from a list with values 2,7,8,3,9,1
max = 0
for each value
if value > max
max = value
else
max = 0 * Remove the clause
What is algorithm time efficiency? The number of calculations required to solve a problem
function myNewFunction(integer x)
z=x-3
returns integer y
What is the parameter? integer x
A function's parameter is the information it needs to execute. This function needs and integer
that it will call x in order to complete.
What happens if you define a function but do not call it? Nothing. The code will simply
remain in memory but will not execute
Using the following function, which portion is the function declaration?
function myFunction(integer b)
a=b-3
returns integer a + b
myFunction(6) function myFunction(integer b)
,Using the following function, which portion calls the function?
function myFunction(integer b)
a=b-3
returns integer a + b
myFunction(6) myFunction(6)
Your user needs to enter a number into the program that will be used throughout its execution.
Before the user enters a number, which loop type can determine how many times the loop will
run? * For
Which loop types are best suited to continually check a test expression? while and do-while
What is the purpose of an "if" statement? To control what code executes based on the
result of a test expression
How many times can you call a function to run? as many times as you want
Fill in the blank so that the loop will iterate 10 times.
for i = 1; _________; i = i + 1; // Loop statements i <= 10
What is put to output by the following pseudocode?
x=4
while x >= 0
Put x to output
x=x-2 420
What is put to output by the following pseudocode?
,x=6
while x > 0
Put x to output
Put " " to output
x=x-2 642
How many times does this loop run?
a=8
b=4
while a % b == 0:
Put a to output
b=b+2 1
David is creating a grade book program for to keep track of his student's scores in a
programming course. This grade book will contain the students' names, email addresses, and
scores on each task.
Which control structure is best to look at the individual grades of each student for Task 1?
Grades are known For loop
Which control structure is best to send continual reminders to submit the upcoming
assignment and ensure that each student receives it at least once? do-while loop
Which control structure is best to assign extra credit work to each student scoring less than 75
on Task 2? if/else statement
Variable declaration Declares a new variable, specifying the variable's name and type
What is a variable? A name that can hold a value. Might be named x. Then, x = 7 assigns x
with 7, which remains in x while the program runs, until x is assigned again.
, Assignment Statement Assigns the variable on the left-side of the = with the current value of
the right-side expression
Expression A mathematical phrase that contains operations, numbers, and/or variables.
numApples is initially 5. What is numApples after:
numApples = numApples + 3; 8
Is the following statement valid?
x+y =y+x Invalid. In programming, the left side of = must be a variable, which will be
assigned with the right side's value. Thus, having x + y on the left side doesn't make sense.
Is the following assignment statement valid?
x+1=3 Valid. The left side must be a variable, not an expression like x + 1. In programming,
= does not mean equal. = means assign the left-side variable with the right-side's value. Thus,
the left side MUST be a variable.
x=9
y=x+1
What is y? 10
What does = mean? Assignment
What is the value of x?
x=2
y=3
x=x*y