Skip to content

This repo is about currency converter that was built using JacLang

Notifications You must be signed in to change notification settings

Shan-Dilranga/Currency_converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Currency Converter

This repository is about currency converter that was built usning Jaclang

The code starts by importing necessary modules:

urllib.request: This module provides functions for working with URLs and making HTTP requests.
json: This module is used for working with JSON data.

with entry{} is acts likes a main function It takes and validates the input (ensuring the amount is numeric and greater than 0).
Finally, it calls the convert_currency function with the provided input and prints the result.

The convert_currency function takes three parameters:

init_currency: The initial currency code (e.g., “USD” for US Dollar).
target_currency: The target currency code (e.g., “EUR” for Euro).
amount: The amount to be converted.

Inside the function:

An API key (you need to replace it with your own) is defined.
A URL is constructed using the provided parameters.
An HTTP request is made to the API using urllib.request.urlopen.
The response is read and decoded as JSON.
If the response contains a “result” field, it returns the conversion result; otherwise, it returns an error message.

About

This repo is about currency converter that was built using JacLang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages