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 diff --git a/weather_script.js b/weather_script.js new file mode 100644 index 00000000..d1540ac0 --- /dev/null +++ b/weather_script.js @@ -0,0 +1,16 @@ +const fetch = require('node-fetch'); + +const apiKey = '6d223ff34e90c880b05d4226788ba497'; +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