Last active
July 5, 2020 15:05
-
-
Save jamad/a081f2e9cc0c23dcfcadcfde704984b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gist - https://gist.github.com/jamad/a081f2e9cc0c23dcfcadcfde704984b6 | |
# executable - | |
# posti.fi/en/private/letters-and-mail/send-a-letter-or-postcard/international-letters-and-cards/economy-letter-abroad | |
''' | |
a=Maximum weight | |
b=Europe Priority | |
c=Europe Economy # commonly used | |
d=Other countries Priority | |
e=Other countries Economy # commonly used | |
a b c d e | |
20 g 1.85 € 1.75 € 1.85 € 1.75 € | |
50 g 2.65 € 2.45 € 3.70 € 2.95 € | |
100 g 3.70 € 3.50 € 7.40 € 4.00 € | |
250 g 5.55 € 5,25 € 12.95 € 7.00 € | |
500 g 9,25 € 8,75 € 22.20 € 12.25 € | |
1000 g 16.65 € 12.25 € 35.15 € 17.50 € | |
2000 g 27,75 € 26,25 € 64.75 € 35.00 € | |
''' | |
def posti_calc(): | |
print() | |
while 1: | |
try: | |
weight=int(input('重さ(g)は? ')) | |
break | |
except:pass | |
print(weight) | |
if weight<=2000: | |
# Maximum Weight 2 kg | |
print('2kg以下なので economy letter を試みます。') | |
calc_economy_letter(weight) | |
else: | |
print('2kgより重いので economy letter にはできません。') | |
def calc_economy_letter(weight): | |
print('running calc_economy_letter - weight:',weight) | |
print('3方向の長さについて質問') | |
width=int(input('横幅(mm)は? ')) | |
height=int(input('高さ(mm)は? ')) | |
depth=int(input('奥行(mm)は? ')) | |
D=[width,height,depth] | |
# condition by dimension | |
# Maximum Dimensions 250 mm x 353 mm x 30 mm We recommend sending larger items as. Alternatively, you can send them as a , which can be delivered at Priority speed | |
# Minimum Dimensions 90 mm x 140 mm | |
a,b,c=sorted(D) | |
print('大きさは短い順に', a ,'x',b,'x', c) | |
message='' | |
if 30<a:message+='一番短い部分が 30mm' | |
if 353<c:message+='一番長い部分が 353mm ' | |
if 250<b:message+='中間部分の長さが 250mm ' | |
if message: | |
print(message+' より大きいので無理でした。終了します') | |
print('Postal parcels か Maxi letter をお勧めします') | |
return | |
if b<90:message+='中間部分の長さが 90mm ' | |
if c<140:message+='一番長い部分が 140mm ' | |
if message: | |
print(message+' より小さいので無理でした。終了します') | |
return | |
eu=input('目的地はEU内ですか? (y or n) ') | |
if eu=='y': | |
print('EU内で送る設定にしました。') | |
price=1.75 if weight<=20 else 2.45 if weight<=50 else 3.5 if weight<=100 else 5.25 if weight<=250 else 8.75 if weight<=500 else 12.25 if weight<=1000 else 26.25 | |
else: | |
print('EUの外に送る設定にしました。') | |
price=1.75 if weight<=20 else 2.95 if weight<=50 else 4 if weight<=100 else 7 if weight<=250 else 12.25 if weight<=500 else 17.5 if weight<=1000 else 35 | |
print(' %.2f € です'%price) | |
return | |
posti_calc() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment