Python Coding Quiz Tutorial
The second course in this series, Introduction to Python Coding for Non-Programmers
, offers Chapter-specific Coding Quizzes to evaluate what you have learned.
In the orientation coding quiz, you will write a simple program that prints the sum of a given integer and 5.
In the code below, the keyword def
is used to define a block of code for a specific task, known as a function
.
solution
is the name of the function, and number
inside the parentheses is the variable to which the function’s input value is assigned.
return
is a keyword that outputs the function’s result, specifically the value that comes after return.
def solution(number):
# Return the value that adds 5 to the given number
return # Write your code here
You can write a function that returns the value of the input number plus 5, as shown below.
def solution(number):
# Return the value that adds 5 to the given number
return number + 5
No need to worry about code that looks like an alien language!
In the Python Introduction Course, concepts such as this will be explained in detail.
You can click the Solution
button at the bottom right to see an example of how to write the function. Click the Submit
button to submit your answer and see if you pass the test.
Input/Output Example
Example 1
-
Input:
1
-
Output:
6
Example 2
-
Input:
10
-
Output:
15
Enter number + 5
next to return
in the code writing area and press the Submit button to pass the test 🙂