演唱會中,歌手應該用什麼語言?

以下程式純屬虛構,現實世界才沒有這麼簡單。

程式

def use_which_language(singer, location):
    print((singer, location))

    location_fan_language_profile = fetch_profile_from_location(location)
    print(location_fan_language_profile)

    person_language_profile = fetch_profile_from_person(singer)
    print(person_language_profile)

    personal_preference = get_personal_preference(singer)
    print(personal_preference)

    personal_comfortable_threshold = get_comfortable_threshold(singer)
    print(personal_comfortable_threshold)

    usable_language = [key for key, fluency in person_language_profile.iteritems() 
                        if fleuncy >= comfortable_threshold]

    print(usable_language)

    scores = {lang: calc_score(
                        fluency,
                        location_fan_language_profile[lang], 
                        personal_preference[lang]
                    ) for lang in usable_language}
    print(scores)

    best_language, best_score = sorted(scores.items(), lambda x: x[1])

    print("Best language:", best_language, "with score", best_score )

    mother_tongue = fetch_mother_tongue_from_location(location)
    print(mother_tongue)

    if mother_tongue in person_language_profile.keys() and mother_tongue != best_language:
        print(f"A bit of {mother_tongue}")
    
    print("-----")

use_which_language("Ado", "Hong Kong")
use_which_language("張學友", "Taiwan")
use_which_language("張學友", "Macau")

輸出

("Ado", "Hong Kong")
{"Cantonese": 1, "English": 0.9, "Mandarin": 0.7, "Japanese": 0.5, ...}
{"Japanese": 1, "English": 0.3, "Cantonese": 0.01, "Mandarin": 0.01, ...}
{"Japanese": 1, "English": 0.3, "Cantonese": 0.1, "Mandarin": 0.1, ...}
0.5
["Japanese"]
{"Japanese": 2.5}
Best language: Japanese with score 2.5
A bit of Cantonese
-----
("張學友", "Taiwan")
{"Mandarin": 1, "Taiwanese": 0.7, "English": 0.6, "Cantonese": 0.3, ...}
{"Cantonese": 1, "Mandarin": 0.7, "English": 0.5, "Taiwanese": 0.01, ...}
{"Cantonese": 1, "Mandarin": 0.8, "English": 0.7, "Taiwanese": 0, ...}
0.5
["Cantonese", "Mandarin", "English"]
{"Cantonese": 2.3, "Mandarin": 2.5, "English": 2.2}
Best language: Mandarin with score 2.5
-----
("張學友", "Macau")
{"Cantonese": 1, "Mandarin": 0.9, "English": 0.3, ...}
{"Cantonese": 1, "Mandarin": 0.7, "English": 0.5, "Taiwanese": 0.01, ...}
{"Cantonese": 1, "Mandarin": 0.8, "English": 0.7, "Taiwanese": 0, ...}
0.5
["Cantonese", "Mandarin", "English"]
{"Cantonese": 3, "Mandarin": 2.4, "English": 1.5}
Best language: Cantonese with score 3
-----