Python-lambda function

Source: Internet
Author: User

Lambda functions are used:

""
Author: sust_ly
function: Exchange rate
Version: 1.0
Date: 2018/3/2

"" "
Str_value = input (' Please enter the amount with units: ') unit
= str _value[-3:]
USD_VS_RMB = 6.77 while
str_value!= ' q ': Unit
    = str_value[-3:]
    USD_VS_RMB = 6.77
    If Unit = = ' CNY ':
        exchange = 1/USD_VS_RMB
    elif unit = = ' USD ':
        exchange = USD_VS_RMB
    Else:
        Exchang E =-1
    If Exchange!=-1: Money
        = eval (str_value[:-3])
        Huilv = Lambda x:x * Exchange
        Out_money = Huil V (Money)
        print ("The converted amount is:%d"% out_money)
    str_value = input (' Please enter the amount with units: ')
print (' End of Program ')

The lambda functions are as follows:

< function name > = lambda < parameter list >: < expression >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.