zoukankan      html  css  js  c++  java
  • python函数练习题1

    写一段代码,用于识别姓名(first_name,last_name)

    结合使用函数get_formatted_name()和while循环,以更正规的方式问候用户

    面尝试使用名和姓跟用户打招呼

    def get_formarted_name(first_name,last_name,middle_name=''):
        if middle_name:
            full_name=first_name+' '+middle_name+' '+last_name
        else:
            full_name=first_name+' '+last_name
        return full_name.title()
    
    while True:
        print("
    Please tell me your name: ")
        f_name = input("First name: ")
        l_name = input("Last name: ")
        m_name = input("Middle name: ")
    
        formatted_name=get_formarted_name(f_name,m_name,l_name)
        print("
    hello, "+formatted_name+"!")
        choice=input("
    Do you want tell me another name? (y or n)")
        if choice == 'y':
            continue
        else:
            break
  • 相关阅读:
    python2和python3的区别
    星球大战
    [USACO]高低卡(金)High Card Low Card (Gold)
    学习笔记
    叶子的染色
    大问题
    ...
    考试前...
    [HAOI2010]计数
    [POI2006]OKR-Periods of Words
  • 原文地址:https://www.cnblogs.com/show530/p/12431631.html
Copyright © 2011-2022 走看看