List soal PWN untuk KSL Seleksi
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

49 líneas
1.8 KiB

hace 6 años
  1. #!/usr/bin/python
  2. import sys
  3. class Unbuffered(object):
  4. def __init__(self, stream):
  5. self.stream = stream
  6. def write(self, data):
  7. self.stream.write(data)
  8. self.stream.flush()
  9. def writelines(self, datas):
  10. self.stream.writelines(datas)
  11. self.stream.flush()
  12. def __getattr__(self, attr):
  13. return getattr(self.stream, attr)
  14. sys.stdout = Unbuffered(sys.stdout)
  15. def hitung(x,z,y):
  16. return eval(x+z+y)
  17. #menu operasi
  18. print " /$$ /$$ /$$$$$$ /$$ /$$$$$$$ /$$ /$$ /$$ /$$"
  19. print "| $$ /$$/ /$$__ $$| $$ | $$__ $$| $$ /$ | $$| $$$ | $$"
  20. print "| $$ /$$/ | $$ \__/| $$ | $$ \ $$| $$ /$$$| $$| $$$$| $$"
  21. print "| $$$$$/ | $$$$$$ | $$ | $$$$$$$/| $$/$$ $$ $$| $$ $$ $$"
  22. print "| $$ $$ \____ $$| $$ | $$____/ | $$$$_ $$$$| $$ $$$$"
  23. print "| $$\ $$ /$$ \ $$| $$ | $$ | $$$/ \ $$$| $$\ $$$"
  24. print "| $$ \ $$| $$$$$$/| $$$$$$$$ | $$ | $$/ \ $$| $$ \ $$"
  25. print "|__/ \__/ \______/ |________/ |__/ |__/ \__/|__/ \__/"
  26. print "Author : Galanggg"
  27. print "===============================================================================>"
  28. print "1. Penjumlahan (+)"
  29. print "2. Pengurangan (-)"
  30. print "3. Perkalian (*)"
  31. print "4. Pembagian (:)"
  32. choice = raw_input("Masukkan pilihan Anda (1/2/3/4): ")
  33. num1 = raw_input("Masukkan Bilangan Pertama : ")
  34. num2 = raw_input("Masukkan Bilangan Kedua : ")
  35. if choice == '1':
  36. print num1,"+",num2,"=",hitung(num1,"+",num2)
  37. elif choice == '2':
  38. print num1,"-",num2,"=",hitung(num1,"-",num2)
  39. elif choice == '3':
  40. print num1,"*",num2,"=",hitung(num1,"*",num2)
  41. elif choice == '4':
  42. print num1,"/",num2,"=",hitung(num1,"/",num2)