From a11fb4e9232823fcbe7178a3cc1e3f624c429fe2 Mon Sep 17 00:00:00 2001 From: Atul Bansal Date: Wed, 18 Dec 2024 05:56:36 +0000 Subject: [PATCH 1/3] Added Calculator --- calculator.js | 41 +++++++++++++++++++++++++++++++++++++++++ hello.py | 1 + 2 files changed, 42 insertions(+) create mode 100644 calculator.js create mode 100644 hello.py diff --git a/calculator.js b/calculator.js new file mode 100644 index 00000000..8e5cfd45 --- /dev/null +++ b/calculator.js @@ -0,0 +1,41 @@ +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +function askQuestion(query) { + return new Promise(resolve => rl.question(query, resolve)); +} + +async function main() { + const num1 = parseFloat(await askQuestion('Enter the first number: ')); + const num2 = parseFloat(await askQuestion('Enter the second number: ')); + const operation = await askQuestion('Enter the operation (+, -, *, /): '); + + let result; + switch (operation) { + case '+': + result = num1 + num2; + break; + case '-': + result = num1 - num2; + break; + case '*': + result = num1 * num2; + break; + case '/': + result = num1 / num2; + break; + default: + console.log('Invalid operation'); + rl.close(); + return; + } + + console.log(`The result is: ${result}`); + rl.close(); +} + +main(); \ No newline at end of file diff --git a/hello.py b/hello.py new file mode 100644 index 00000000..4648e701 --- /dev/null +++ b/hello.py @@ -0,0 +1 @@ +print("Hello, World!") \ No newline at end of file From ae8caf3c30d9cbeaced15b3439ad1320e1988c54 Mon Sep 17 00:00:00 2001 From: Atul Bansal Date: Wed, 18 Dec 2024 06:15:26 +0000 Subject: [PATCH 2/3] Weather API --- weather_script.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 weather_script.js diff --git a/weather_script.js b/weather_script.js new file mode 100644 index 00000000..1caf6a28 --- /dev/null +++ b/weather_script.js @@ -0,0 +1,16 @@ +const fetch = require('node-fetch'); + +const apiKey = 'YOUR_API_KEY'; +const city = 'London'; +const url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}`; + +fetch(url) + .then(response => response.json()) + .then(data => { + console.log(`Weather in ${city}:`); + console.log(`Temperature: ${data.main.temp}K`); + console.log(`Weather: ${data.weather[0].description}`); + }) + .catch(error => { + console.error('Error fetching weather data:', error); + }); \ No newline at end of file From 4a7071e188fe3a35505ac8992fdb3f21074b515a Mon Sep 17 00:00:00 2001 From: Atul Bansal Date: Wed, 18 Dec 2024 06:27:52 +0000 Subject: [PATCH 3/3] Added app key in weather api --- weather_script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather_script.js b/weather_script.js index 1caf6a28..d1540ac0 100644 --- a/weather_script.js +++ b/weather_script.js @@ -1,6 +1,6 @@ const fetch = require('node-fetch'); -const apiKey = 'YOUR_API_KEY'; +const apiKey = '6d223ff34e90c880b05d4226788ba497'; const city = 'London'; const url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}`;