Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.


Introduction

Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def sum_thrice(x, y, z):
  2.  
  3. sum = x + y + z
  4.  
  5. if x == y == z:
  6. sum = sum * 3
  7. return sum
  8.  
  9. print(sum_thrice(1, 2, 3))
  10. print(sum_thrice(3, 3, 3))

Result

python language techstudy.org

     





Related Topics




Popular Posts