List soal PWN untuk KSL Seleksi
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

50 wiersze
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)