Skip to content

Instantly share code, notes, and snippets.

public static void main(String[] args) {
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight/EARTH.surfaceGravity();
for (Planet p : Planet.values())
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(mass));
}
public static void main(String[] args) {
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight/EARTH.surfaceGravity();
for (Planet p : Planet.values())
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(mass));
}
@alex-ber
alex-ber / fix-wsl2-dns-resolution.md
Last active February 3, 2024 22:42
Fix DNS resolution in WSL2
  1. Open PowerShell as Administator. Type Get-DnsClientServerAddress (similar to ipconfig /all) Look upon Ethernet. Ignore 0.0.0.0. In my case the only IP is 192.168.1.1

  2. In the bash terminal of WSL2: Append following text:

[network]

generateResolvConf = false

delim = ","
msg = f"Hello{delim} world!"
print(msg)
@alex-ber
alex-ber / 03_int3.py
Last active September 13, 2022 20:27
03_int3.py
a = 7
b = 2
c1 = a // b
r = a % b
print(f'integer division is {c1} of type {type(c1)}')
print(f'reminder is {r}')
c2 = a / b
@alex-ber
alex-ber / 02_bool2.py
Created September 8, 2022 20:55
02_bool2.py
if(0 and True):
print("if")
else:
print("else")
if(2 or True):
print("if")
else:
print("else")
@alex-ber
alex-ber / 01_bool1.py
Created September 8, 2022 20:16
01_bool1.py
print(0 and True)
print(2 and True)
print(0 or True)
print(2 or True)
@alex-ber
alex-ber / 05_import5.py
Created September 7, 2022 21:15
05_import5.py
from simplemathexample.const import *
from simplemathexample.const import _random
first=FIRST
second=SECOND
result=first+second
answer_str = input(f"How much is {first} + {second} ? ")
answer = int(answer_str)
if result==answer:
@alex-ber
alex-ber / 04_import4.py
Created September 7, 2022 20:43
04_import4.py
print(__name__)
from simplemathexample.const import FIRST as first, SECOND as second
print('04_import4')
result=first+second
answer_str = input(f"How much is {first} + {second} ? ")
answer = int(answer_str)
if result==answer:
print("You're right!")
else:
@alex-ber
alex-ber / const.py
Last active September 7, 2022 21:03
const.py
print(__name__)
import random as _random
FIRST = _random.randint(1, 9)
SECOND = _random.randint(1, 9)