Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions calculator.js
Original file line number Diff line number Diff line change
@@ -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();
1 change: 1 addition & 0 deletions hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello, World!")
16 changes: 16 additions & 0 deletions weather_script.js
Original file line number Diff line number Diff line change
@@ -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);
});