Guidelines

Python Coding Quiz Tutorial

The Python course provides coding quizzes per chapter to assess the learned material.

In this tutorial, we'll write a simple program that outputs the value obtained by adding 5 to a given integer.

In the code below, def is a keyword that defines a block of code performing a specific task, known as a function.

solution denotes the name of the function, and number inside the parentheses is a variable that receives the function's input value.

return is a keyword that returns the result of a function, with the value following it being returned as the function's result.

Output the value obtained by adding 5 to a given number
def solution(number): return # Write your code here

A function that returns the value obtained by adding 5 to the input number can be written as follows:

Output the value obtained by adding 5 to a given number
def solution(number): # Return the value obtained by adding 5 to the given number return number + 5

You can check out the example solution by clicking the Show Solution button at the bottom right and submit your answer using the Submit button to see if you pass the test.



Input/Output Examples

Example 1

  • Input: 1

  • Output: 6


Example 2

  • Input: 10

  • Output: 15


Enter number + 5 next to return in the code editor on the right and click the Submit button to pass the test πŸ™‚

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help