Answer to Question #107526 in Python for Patrick

Question #107526
Write a function named print_sum that accepts three numbers as parameters and prints the sum
1
Expert's answer
2020-04-02T10:11:30-0400

#!/usr/bin/env python3


import sys


def print_sum(a, b, c):

  try:

    a = float(a)

    b = float(b)

    c = float(c)

  except ValueError:

    print("Function acceps numbers. Program will be stopped.")

    sys.exit(0)

  return a + b + c

     

if __name__ == "__main__":

  print(print_sum(0, 5, 10))

  print(print_sum(-1.5, 2.75, -10))

  print(print_sum(0, 5, 'b'))


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS