For the multiple-choice questions, type your answer into the _highlighted blank (like this)____ In the while loop below, given that k = 0 initially, what is the value of k after execution of the loop? ___e__ while (k <= 5) { k = k + 1; } 0 1 4 5 6 none of the above
For the multiple-choice questions, type your answer into the _highlighted blank (like this)____
- In the while loop below, given that k = 0 initially, what is the value of k after execution of the loop? ___e__
while (k <= 5)
{
k = k + 1;
}
- 0
- 1
- 4
- 5
- 6
- none of the above
2) A _____is a sequence of instructions with a name.
- variable
- argument
- parameter
- function
3) Consider the following function call round(3.14159, 3) what is the return value? _____
- 3.14159
- 3.141
- 3.14
- 3.1
4) Operators such as greater-than and less-than, used to compare data for conditions, are called _____operators.
- logical
- arithmetic
- relational
- smooth
5) The Python syntax to assign the value 10 to the variable count is _____.
- count = 10;
- count == 10;
- count is = 10;
- 10 == count;
6) Consider the following function.
def factorial(n) :
result = 1
for i in range(1, n + 1) :
result = result * i
return result
What is the parameter for this function? _____
- factorial
- i
- n
- result
7) A condition such as "pcount < 20" has a _____value.
- numeric
- alphanumeric
- character
- boolean
8) The Python condition to test the value of count to be equal to the value 10 is _____.
- (count = 10)
- (count == 10)
- (count.equal(10))
- (count is = 10)
9) Corrections to syntax to eliminate syntax, runtime, or logic errors must be made to the _____.
- compile code
- executable code
- object code
- source code
- none of the above
10) What are supplied to a function when it is called? _____
- arguments
- numbers
- return values
- sentinals
11) “Fix” the following 3 lines of code so that the print the last line of code correctly:
age == input(How old are you?)
age == age + 1
print["Happy birthday! You are" + age + years old!]
12) Consider the following function:
def squareArea(sideLength) :
return sideLength ** 2
What is the value of squareArea(3)? _____
a.2
b.3
c.6
d.9
13) Using one line or two of Python code, declare a one-dimensional list called cityNames, and assign the values: Providence, Denver, Miami, Chicago, Seattle
14) Given the array you created above, what is the output of the line of Python below:
print(cityNames[3]) ________________
15) Given the array above, write a for statement (using Python syntax) that will output all of the entries in the array, one name at a time (one name per line)
16) Assume you are working in a Python program and you have been given the following lines of Python code
studentFirstName = “Pat”
studentLastName = “Brown”
studentFullName = concatNames(studentFirstName, studentLastName)
Assume there is currently no method called concatNames in the file you are working on. In the space below, write the Python code to create a method called concatNames that will take in two values called fName and lName. The method should concatenate the names and return the full name of the student as one String called totalName.
17) In the space below, write a function
Def countVowels(wordPhrase):
that returns a count of all vowels in wordPhrase. Vowels are the letters a, e, i, o, u, and their uppercase variants.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images