current position:Home>How does Python code calculate the total cost of cross-border e-commerce in different countries

How does Python code calculate the total cost of cross-border e-commerce in different countries

2022-02-03 02:37:00 CSDN Q & A

Hope to provide some ideas :
Country : Russia The United States The British
Corresponding country freight :11 21 13
Cost of goods :5( Need to enter )
The total cost = Corresponding country freight + Cost of goods
How to directly export the total cost of these three countries




Refer to the answer 1:

Country 、 The cost of goods needs to be entered .
You can use a dictionary to store the country and the corresponding freight .
Find the corresponding freight through the entered country to calculate .




Refer to the answer 2:



Refer to the answer 3:

Write the country and freight into a list respectively , Calculate the result with the list analytic formula :

country=[' Russia ',' The United States ',' The British ']fee=[11,21,13]cost=int(input())total_cost=[(c,f+cost)for c,f in zip(country,fee)]for res in total_cost:    print(res[0],' The total cost :',res[1])



Refer to the answer 4:



Refer to the answer 5:
data_dict = { " Russia ":11, ' The United States ': 21,' The British ': 13,}price = float(input(">>>"))res = {k:v +price for k, v in data_dict.items()}print(res)#  You know, the of a country is :country = input(">>>")print(f"{country}:  The total cost is  {res.get(country,' nothing ')}")



Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030236593581.html

Random recommended