List soal PWN untuk KSL Seleksi
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

50 lignes
1.8 KiB

#!/usr/bin/python
import sys
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def writelines(self, datas):
self.stream.writelines(datas)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
def hitung(x,z,y):
return eval(x+z+y)
#menu operasi
print " /$$ /$$ /$$$$$$ /$$ /$$$$$$$ /$$ /$$ /$$ /$$"
print "| $$ /$$/ /$$__ $$| $$ | $$__ $$| $$ /$ | $$| $$$ | $$"
print "| $$ /$$/ | $$ \__/| $$ | $$ \ $$| $$ /$$$| $$| $$$$| $$"
print "| $$$$$/ | $$$$$$ | $$ | $$$$$$$/| $$/$$ $$ $$| $$ $$ $$"
print "| $$ $$ \____ $$| $$ | $$____/ | $$$$_ $$$$| $$ $$$$"
print "| $$\ $$ /$$ \ $$| $$ | $$ | $$$/ \ $$$| $$\ $$$"
print "| $$ \ $$| $$$$$$/| $$$$$$$$ | $$ | $$/ \ $$| $$ \ $$"
print "|__/ \__/ \______/ |________/ |__/ |__/ \__/|__/ \__/"
print "Author : Galanggg"
print "===============================================================================>"
print "1. Penjumlahan (+)"
print "2. Pengurangan (-)"
print "3. Perkalian (*)"
print "4. Pembagian (:)"
choice = raw_input("Masukkan pilihan Anda (1/2/3/4): ")
num1 = raw_input("Masukkan Bilangan Pertama : ")
num2 = raw_input("Masukkan Bilangan Kedua : ")
if choice == '1':
print num1,"+",num2,"=",hitung(num1,"+",num2)
elif choice == '2':
print num1,"-",num2,"=",hitung(num1,"-",num2)
elif choice == '3':
print num1,"*",num2,"=",hitung(num1,"*",num2)
elif choice == '4':
print num1,"/",num2,"=",hitung(num1,"/",num2)