• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 6th, 2020 158 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # Program Kalkulator Python
2.
5.     return a + b
6.
7. # Function Substract
8. def substract(a, b):
9.     return a - b
10.
11. # Function Divide
12. def divide(a, b):
13.     return a / b
14.
15. # Function Multiply
16. def multiply(a, b):
17.     return a * b
18.
19.
20. print("Pilih operasi.")
21. print("1. + Tambah")
22. print("1. - Kurang")
23. print("1. / Bagi")
24. print("1. * Kali")
25.
26. #input
27. choice = input("Pilih (1/2/3/4): ")
28.
29. num1 = float(input("Masukan Angka Pertama: "))
30. num2 = float(input("Masukan Angka Kedua: "))
31.
32. #Func
33.
34. if choice == '1':
35.     print(num1, "+" ,num2, "=", add(num1, num2))
36.
37. if choice == '2':
38.     print(num1, "-" ,num2, "=", substract(num1, num2))
39.
40. if choice == '3':
41.     print(num1, "/" ,num2, "=", divide(num1, num2))
42.
43. if choice == '4':
44.     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.
Top