CBSE Class 12 Computer Science
Question 90 of 103
Working with Functions — Question 23
Back to all questions1. def print_number(number):
2. next_number = number + 1
3. print("The number following", number, "is", next_number)
4. print_number(4)
5. print_number(6)
6. print_number(8)
7. print_number(2 + 1)
8. print_number(4 - 3 * 2)
9. print_number(- 3 - 2)The print_number following 4 is 5
The print_number following 6 is 7
The print_number following 8 is 9
The print_number following 3 is 4
The print_number following -2 is -1
The print_number following -5 is -4
def print_number(number)— This line defines a function namedprint_numberthat takes one argumentnumber.next_number = number + 1— Inside theprint_numberfunction, this line calculates the next number after the input number by adding 1 to it and assigns the result to the variablenext_number.print("The number following", number, "is", next_number)— Inside theprint_numberfunction, this line prints a message stating the number and its following number.Then the
print_numberfunction is called multiple times with 4, 6, 8, 3 ,((4 - 3 * 2) = -2), ((-3-2) = -5) as arguments.