V
Size: a a a
V
БГ
БГ
V
БГ
from decimal import getcontext, Decimal as dec
getcontext().prec = 5000
prob = 1-(dec(2)**(-112))
def probability(x):
return (1-prob**x)
start_dec_power = 26
_n = 10**start_dec_power
for n in range(start_dec_power, 100):
p = probability(_n)
rounded = round(p, 6)
percent = rounded*100
print("10^{}:\t{}%".format(n, percent))
_n*=10
if percent>99.99:
break
БГ
V
БГ
БГ
from subprocess import Popen, PIPE
from sys import stdin, stdout
class Shell:
def __init__(self, livemode=False, printmode=False):
kwargs = {
"stdout": PIPE,
"stderr": PIPE,
"shell" : True
}
self.livemode = livemode or printmode
if livemode:
kwargs["stdout"] = stdout
kwargs["stdin"] = stdin
if printmode:
kwargs["stdout"] = stdout
self.kwargs = kwargs
def sh_wrapper(self, cmd):
def bash(*args, env=None, timeout=None):
args = " ".join(args)
sh_args = "{} {}".format(cmd, args)
proc = Popen(
sh_args, **self.kwargs, env=env
)
proc.wait(timeout)
if not self.livemode:
out = proc.stdout.read().decode()
err = proc.stderr.read().decode()
if proc.returncode:
return "Error" + "\n" + err
if not out:
return err
return "{}\n{}".format(out, err)
return bash
def __getattr__(self, attr):
return self.sh_wrapper(attr)
s = Shell(printmode=True)
print(s.source(timeout=10))
print(s.ping("127.0.0.1", timeout=5))
БГ
V
a
БГ
БГ
V
БГ
БГ
V
V
БГ