7.3 Code Practice edhesive

Write a function named print_sum that accepts three numbers as parameters and prints the sum. First, write the print_sum function. Then, prompt the user for three inputs, and call your print_sum function on those inputs.

Sample Run:
Enter the 1st number: 11
Enter the 2nd number: 9
Enter the 3rd number: 8
The sum: 28

Respuesta :

def print_sum(a,b,c):

   print(a+b+c)

one = int(input("Enter the 1st number: "))

two = int(input("Enter the 2nd number: "))

three = int(input("Enter the 3rd number: "))

print_sum(one,two,three)

I wrote my code in python 3.8. I hope this helps.

Following are the python program to the given question:

Program Explanation:

  • Defining a method "print_sum" that takes three parameters "n, x, g".
  • Inside the method, a "print" method is used that adds the value of the parameters and prints its value with the message.
  • In the next step, the "n, x, g" variable is defined that inputs and store its value.
  • At the last, the "print_sum" method calls that accept values.

Program:

def print_sum(n,x,g):

   print("The Sum : ",n+x+g)

n=int(input("Enter the 1st number: "))

x=int(input("Enter the 2nd number: "))

g=int(input("Enter the 3rd number: "))

print_sum(n,x,g)

Output:

Please find the output file in the attachment.

Learn more:

brainly.com/question/16690412

Ver imagen codiepienagoya