def orbit_speed(body, distance_from_surface, periapsis, apoapsis): if type(body) != bodies.Body: raise TypeError("'body' argument was not a bodies.Body object") semi_major_axis = ((periapsis * _kilo) + (body.equatorial_radius * 2) + (apoapsis * _kilo)) / 2 orbit_speed = root( body.mu * ((2 / (distance_from_surface + body.equatorial_radius)) - (1 / semi_major_axis))) pass return (orbit_speed)
max_mag_x, max_mag_y, max_mag_z = 0, 0, 0 min_acc_x, min_acc_y, min_acc_z = 0, 0, 0 min_mag_x, min_mag_y, min_mag_z = 0, 0, 0 acc_x_range, acc_y_range, acc_z_range = 0, 0, 0 mag_x_range, mag_y_range, mag_z_range = 0, 0, 0 max_acc_magnitude = 0 max_mag_magnitude = 0 count = 0 t_end = time() + 60 * 3 # run for 3 minutes while time() < t_end: acc_x, acc_y, acc_z = acc_sensor.acceleration mag_x, mag_y, mag_z = mag_sensor.magnetic acc_magnitude = root((acc_x**2) + (acc_y**2) + (acc_z**2)) mag_magnitude = root((mag_x**2) + (mag_y**2) + (mag_z**2)) if max_acc_x < acc_x: max_acc_x = acc_x if max_acc_y < acc_y: max_acc_y = acc_y if max_acc_z < acc_z: max_acc_z = acc_z if max_mag_x < mag_x: max_mag_x = mag_x if max_mag_y < mag_y: max_mag_y = mag_y if max_mag_z < mag_z: max_mag_z = mag_z
def generate_masks(self, batch): return self.sampler(batch, 3, *self.resolution) / root(self.resolution[0] * self.resolution[1])
from math import sqrt as root x=float(input('Introduzca variable x: ')) y=float(input('introduzca variable y: ')) if (x < 0) or (y < 0): print('variables no válidas') elif (x == 0) and (y == 0): print('variables no válidas') else: r=root(3*(x**2)+(6*y)) print(r)
import math while True: num = input("Please enter a number") if (int(num) < 0): raise RuntimeError("Don't use a negative...please") else: print(abs(math.root(int(num))))
def get_fall_time(d): time = root(2 * d / GRAVITY) return time
def get_fall_time(d, grav=GRAVITY): time = root(2 * d / grav) return time
from math import sqrt as root while (1): try: a, b, c = map(int, input().split()) s = (a + b + c) / 2 ans = (4 * root(s * (s - a) * (s - b) * (s - c))) / 3 if ans > 0: print("%.3f" % ans) else: print('-1.000') except EOFError: break
#multi line comment using """ """ this is a multi line comment in pyhton """ print("------------------------\n") #using modules from math import sqrt as root num = 36 print(root(num)) print("------------------------\n") #excemption handlig try: num1 = 5 num2 = 0 print(num1 / num2) print("line after excemption \n") except ZeroDivisionError: print("Error found\n Zero Division error \n") finally: print("this is finall print\n") print("------------------------\n") #assertion
from math import sqrt as root a, b = map(int, input().split()) m = [-a + root(a**2 - b), -a - root(a**2 - b)] if m[0] == m[1]: print(int(m[0])) else: print(int(sorted(m)[0]), int(sorted(m)[1]))
def random_theta(self,i): units = self.units einit = root(6) / ( root( units[i]) + root(units[i+1]) ) theta = np.random.random(( units[i+1],units[i]+1) )*2*einit - einit return theta
def root(n): from math import sqrt as root return root(n)
def __call__(self, x): h = self.a2(self.c2(self.a1(self.c1(x)))) return (self.skip(x) + self.down(h)) / root(2)
import random from math import pi,sqrt from math import sqrt as root print (random.randint(0,10)) print (sqrt(25)) print (pi) print (root(25))
from math import sqrt as root suc=20 mer=0 i=0 while i<suc: i=i+1 mer=1/(2+mer) salida=1+mer print("el resultado aproximado es "+salida) print("El resultado exacto es "+str(root(2)))
def __init__(self, side_length=1): super().__init__(8, side_length) self.height = self.apothem * 3 self.width = self.side_length self.long_diagonal = self.side_length * math.root(4 + 2 * math.root(2)) self.short_diagonal = math.root(3) * self.side_length