WorksheetsFunctions With Return Values U1M2 Python
Total questions: 12
Worksheet time: 6mins
Function names cannot begin with a number as the first character.
True
False
def showName():
print("Tobias Ledford")
Which code below calls the function in the above code?
showName.run()
open(showName)
run showName
showName()
A function with 2 integer parameters could start with which definition?
funct addNumbers(num1, num2):
def addNumbers(num1, num2):
def 2Numbers(num1, num2):
FUNCTION addNumbers(x, y):
def addNum(num1 = 10):
print(num1 + num1)
Choose the correct output of calling the above function using the following code:
addNum()
0
10
20
An Error
Python Function return values must be stored in variables.
True
False
def addNum(num1 = 10):
return num1 + num1
Choose the correct output of calling the function above using the following code:
print(addNum(100))
20
100
200
an error
def addNumbers(num1, num2 = 10):
return num1 + num2
Choose the correct output of calling the function above using the following code:
print(addNumbers(100))
100
110
200
An Error
def lowCase(wordsIn):
return wordsIn.lower()
Choose the correct output of calling the function above using the following code:
wordsLower = lowCase("Return THIS lower")
print(wordsLower)
"Return THIS lower"
No Output
"return this lower"
An Error
Function calls should be placed at the beginning of a code page, and functions should be placed later and toward the end of the code.
True
False
1.name = input("enter your name")
2. print(name, "your score is", score)
3. score = 199
Order the above numbered code lines into the proper sequence.
1,2,3
2,3,1
3,1,2
3,2,1
1.
2. score = add_score(190)
3.
4. print(name, "your score is", score)
5.
At which line above should the following add_score() function definition be inserted so the program runs without error?
def add_score(current):
return current + 10
line 1
line 3
line 5
any of the above
1. greet(name)
2. name = input("enter your name: ")
3. greet(name)
4. def greet(person): u
5. print("Hi,", person)
6. greet(name)
Which line or lines need to be removed from the above code so the program prints a greeting without error?
lines 1 and 2
lines 1 and 3
line 1 only
line 3 only
