G2A Many GEOs
SHARE
TWEET

Calculator.py

a guest Apr 6th, 2020 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Program Kalkulator Python
  2. # JecoNick
  3.  
  4. # Function Add
  5. def add(a, b):
  6.     return a + b
  7.  
  8. # Function Substract
  9. def substract(a, b):
  10.     return a - b
  11.    
  12. # Function Divide
  13. def divide(a, b):
  14.     return a / b
  15.    
  16. # Function Multiply
  17. def multiply(a, b):
  18.     return a * b
  19.    
  20.  
  21. print("Pilih operasi.")
  22. print("1. + Tambah")
  23. print("1. - Kurang")
  24. print("1. / Bagi")
  25. print("1. * Kali")
  26.  
  27. #input
  28. choice = input("Pilih (1/2/3/4): ")
  29.  
  30. num1 = float(input("Masukan Angka Pertama: "))
  31. num2 = float(input("Masukan Angka Kedua: "))
  32.  
  33. #Func
  34.  
  35. if choice == '1':
  36.     print(num1, "+" ,num2, "=", add(num1, num2))
  37.    
  38. if choice == '2':
  39.     print(num1, "-" ,num2, "=", substract(num1, num2))
  40.  
  41. if choice == '3':
  42.     print(num1, "/" ,num2, "=", divide(num1, num2))
  43.  
  44. if choice == '4':
  45.     print(num1, "x" ,num2, "=", multiply(num1, num2))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top