Computer Science, asked by gapiwe, 10 months ago

please find below image as your question to be answered

Attachments:

Answers

Answered by rakeshchennupati143
0

Program:

def convert_currency(amount_needed_inr,current_currency_name):

   current_currency_amount=-1

   curr_name = ["Euro","British Pound","Australian Dollar","Canadian Dollar"]

   curr_conv = [0.01417,0.0100,0.02140,0.02027]

   i = 0

   while i<4:

       if curr_name[i] == current_currency_name:

           current_currency_amount = amount_needed_inr * curr_conv[i]

       i = i + 1

   return current_currency_amount

a = int(input("Enter money in your currency"))

b = input("Enter your currency")

currency_needed=convert_currency(a,b)

if(currency_needed!= -1):

   print(currency_needed )

else:

   print("-1")

Explanation:

  • as you can see i wrote the logic in a function
  • then defined country names and their currency to an array respectively
  • then i started loop and check whether the taken currency_name is equal to the an one of the currency_name in the array
  • if true then i calculate the amount to be transferred from rupees to those particular country currency
  • at last i returned the calculated currency and checked if the calculated currency is -1 or not
  • then printed the currency needed amount.

---mark brainliest if you like my answer  :)

Similar questions