Draft100


 * 1) !/usr/bin/python

import math import sys

Mvis = float(sys.argv[1]) Dist = float(sys.argv[2])

Vabs = Mvis - 5 * (math.log10(Dist / 3.2616) -1)

print round(Vabs,3)
 * 1) !/usr/bin/python

import sys from math import factorial

s = sys.argv[1]

from math import factorial def perm(s): for i in range(factorial(len(s))): print(''.join(s)) p=len(s)-1 while (p > 0) and (s[p-1] > s[p]): p=p-1 s[p:] = reversed(s[p:]) if p > 0: q = p            while s[p-1] > s[q]: q=q+1 s[p-1],s[q]=s[q],s[p-1]

s = list(s) s.sort perm(s)


 * 1) !/usr/bin/python3

from itertools import permutations import sys input=sys.stdin.read input=input.strip

anagrams = permutations(input,len(input)) anagrams2 = [''.join(element) for element in anagrams] anagrams3 = '\n'.join(anagrams2)
 * 1) anagrams = [''.join(element) for element in (permutations(input,len(input)))]

for i in anagrams3: sys.stdout.write(str(i))

sys.stdout.write("\n")


 * 1) !/usr/bin/python3

from itertools import permutations import sys input=sys.argv[1]

def common(a,b): a=set(a) b=set(b)

with open("words.txt","r") as f:   lines = [] for line in f:            lines.append(line.strip) anagrams = [''.join(element) for element in (permutations(input))] print (str(common(anagrams,lines)))

import math h = float(input("Parabola height? ")) w = float(input("Parabola width? ")) l = math.log(((4 * h) + math.sqrt(w**2+ 16 * h**2)) / w) * w**2 / (8 * h) + (math.sqrt((w**2 + 16 * h **2))) / 2 print(f"Arc length = {l}")
 * 1) !/usr/bin/python3

data =[3546,3027,22,99,3208,348,77,1398,8567,2866,99,66,4272,2784,4429,88,3286,86,55,1766] from numpy import mean elements = [float(elements) for elements in data] print (mean(elements))
 * 1) !/usr/bin/python3

print '\n'.join("%i Byte = %i Bit = largest number: %i" % (j, j*8, 256**j-1)

for j in (1 << i for i in range(8))) print '\n'.join("%i Byte = %i Bit = largest number: %i" % (j, j*8, 256**j-1) for j in (1 << i for i in range(8)))
 * 1) !/usr/bin/python3

import sys import math

x = float(sys.argv[1])

def cosine(x,y): cos = 0 for n in range (y): cos += ((-1)**n) * (x ** (2*n)) / (math.factorial(2 * n)) return cos

for i in range (1,16): print (math.cos(x),cosine(x,i))

4,15,56,17,64,56,35,67,31,24,66,21,79,86,27,9,0,98,41,63 import numpy n = numpy.array(1,4],[-2,-3) print (n) det = numpy.linalg.det(n) print (round(det,3)) import numpy n = numpy.array(55,25,15],[30,44,2],[11,45,77) print (n) det = numpy.linalg.det(n) print (round(det,3)) import numpy n = numpy.array(4,3,2,3],[0,1,-3,3],[0,-1,3,3],[0,3,1,1) print (n) det = numpy.linalg.det(n) print (round(det,3))
 * 1) !/usr/bin/python3

import numpy import sys

matrix[1] = float(sys.argv[1]) matrix[2] = float(sys.argv[2]) matrix[3] = float(sys.argv[3]) matrix[4] = float(sys.argv[4])

n = numpy.array(matrix) print (n) det = numpy.linalg.det(n) print (det) import numpy n = numpy.array(55,25,15],[30,44,2],[11,45,77) print (n) det = numpy.linalg.det(n) print (round(det,3))
 * 1) !/usr/bin/python3

import sys

a=int(sys.argv[1]) b=int(sys.argv[2])

for y in range (a, b+1, 1): c=y//100;n=y-19*(y//19);k=(c-17)//25;i=c-c//4-(c-k)//3+19*n+15 i=i-30*(i//30);i=i-(i//28)*(1-(i//28)*(29//(i+1))*((21-n)//11)) j=y+y//4+i+2-c+c//4;j=j-7*(j//7);l=i-j;m=3+(l+40)//44;d=l+28-31*(m//4) print (m,d,y,sep="/")


 * 1) !/usr/bin/python3

import sys import math from numpy import arange

start = float(sys.argv[1]) stop = float(sys.argv[2]) step = float(sys.argv[3])

for x in arange(start, stop, step): print (round(x,2),round(math.gamma(x),8))
 * 1) !/usr/bin/python3

def gcd(a, b): if b == 0: return a   return gcd(b, a % b)

print ("x","y","gcd","lcm")

for y in range (1,10,1): for x in range (y,10,1): print ("%d " % y, "%d " % x, gcd (x, y),x* y / gcd (x,y))


 * 1) !/usr/bin/python3

import scipy.integrate as integrate import sys

ll=float(sys.argv[1]) ul=float(sys.argv[2])

result = integrate.quad(lambda x: x**2-x+1, ll, ul) print (result[0])

import scipy.integrate as integrate result = integrate.quad(lambda x: x**2, 0, 5) print (result[0])

import sys, numpy
 * 1) !/usr/bin/python3

def g(a,b): if (a == 0): return b   return g(b%a,a) def l(b,i): if (i == len(b)-1): return b[i] a = b[i] b = l(b,i+1) return int(a*b/g(a,b))

a = sys.argv[1:] b = numpy.array(a,dtype=int) print (l(b,0))

import sys, numpy

def g(a, b): if (a == 0): return b   return g(b % a, a)

def l(b,i): if (i == len(b)-1): return b[i] a = b[i] b = l(b, i+1) return int(a * b / g (a,b))

a = sys.argv[1:] b = numpy.array(a,dtype=int) print (l(b,0))
 * 1) !/usr/bin/python3

for i in range(2, 9, 2): print("%d " % i, end="\n") print("who do we appreciate?\n") print("Arclight!")


 * 1) !/usr/bin/python3

import random random.seed items = [*range(1,50)]

for i in range (0,10): print (random.sample(items,6))


 * 1) !/usr/bin/python

import math

a=["Sol","A Centauri","E Eridani","Procyon","E Indi","Tau Ceti","40 Eridani","70 Ophiuchi"] x=[0,-1.643,6.197,-4.769,5.658,10.28,7.195,0.394] y=[0,1.374,8.294,10.31,-3.157,5.018,14.63,-16.57] z=[0,-3.838,-1.725,1.039,-9.896,-3.267,-2.191,0.723]

for i in range(0,8): for w in range(i+1,8): print round(math.sqrt((x[i]-x[w])**2 + (y[i]-y[w])**2 + (z[i]-z[w])**2),3),"light-years from ", a[i],"to", a[w]


 * 1) !/usr/bin/python3

import math

mu = 398600 r = 6378

print ("Altitude (km)","\t\t","Velocity (km/sec)") for i in range (100,3500,100): print (i,"\t\t\t",round(math.sqrt(mu/(r+i)),3))


 * 1) !/usr/bin/python

def words(fileobj): for line in fileobj: for word in line.split: yield word

with open("words.txt") as wordfile: wordgen = words(wordfile) for word in wordgen: if word == word[::-1]: print(word),
 * 1) !/usr/bin/python

def words(obj): for line in obj: for word in line.split: yield word

with open("words.txt") as wordfile: gen = words(wordfile) for word in gen: if word == word[::-1]: print(word),
 * 1) !/usr/bin/python3

import sys import numpy

elements = sys.argv[1:] a=numpy.array(elements,dtype=float) print (str(elements), '->', str(1/sum(1/a)),'\n')
 * 1) !/usr/bin/python3

import sys with open ("col1.txt","r") as test1: lines1 = test1.readlines with open ("col2.txt","r") as test2: lines2 = test2.readlines

for i in range (0,46,1): sys.stdout.write(lines1[i].rstrip) sys.stdout.write(" ") sys.stdout.write(lines2[i])


 * 1) !/usr/bin/python

from decimal import Decimal as d from decimal import getcontext as g

g.prec = 40 s = d(1); pi = d(3); for i in range(2, 60, 2): pi = pi + s * (d(4) / (d(i) * (d(i) + d(1)) * (d(i) + d(2)))) s = -1 * s   print (pi)

import math Diameter_moon=2159 Distance_moon=238855 Diameter_sun=864938 Distance_sun=92955807 math.degrees(math.atan2(Diameter_moon,Distance_moon)) math.degrees(math.atan2(Diameter_sun,Distance_sun))
 * 1) !/usr/bin/python3

import sys

m=int(sys.argv[1]) n=int(sys.argv[2])

primes = [i for i in range(m,n) if all(i%j !=0 for j in range(2,int(i**0.5) + 1))]

print(primes) import cmath,sys a = float(sys.argv[1]) b = float(sys.argv[2]) c = float(sys.argv[3]) d = (b**2) - (4*a*c) x1 = (-b-cmath.sqrt(d))/(2*a) x2 = (-b+cmath.sqrt(d))/(2*a) print('Roots: {0} and {1}'.format(x1,x2)) import random,sys z = int(sys.argv[1]) seq = [] for i in range(0,z): x = random.random seq.append(x) for i in seq: sys.stdout.write(str(i)) sys.stdout.write("\n")
 * 1) !/usr/bin/python3
 * 1) !/usr/bin/python

import sys x1=float(sys.argv[1]) y1=float(sys.argv[2]) x2=float(sys.argv[3]) y2=float(sys.argv[4]) m=(y2-y1)/(x2-x1) b=y1/(m*x1) print 'y =',m,'x +',b
 * 1) !/usr/bin/python

import math Diameter_moon=2159 Distance_moon=238855 Diameter_sun=864938 Distance_sun=92955807 print (math.degrees(math.atan2(Diameter_moon,Distance_moon))) print (math.degrees(math.atan2(Diameter_sun,Distance_sun)))
 * 1) !/usr/bin/python3

import sys import math

au = 149598023 mu = 1.32712E11 r1 = au * float(sys.argv[1]) r2 = au * float(sys.argv[2]) e = (r1 + r2)**3 f = mu * 8 i = math.pi * math.sqrt(e / f) print (round((i / 3600 / 24),2))


 * 1) !/usr/bin/python3

import math import numpy

s = float(input("Apparent wind speed: ")) b = float(input("True boat speed: ")) d = float(input("Apparent wind direction: "))

r = numpy.radians(d) w = round(math.sqrt(s**2 + b**2 - (2 * s * b * math.cos(r))),1) h = round(numpy.degrees(numpy.arccos((s * math.cos(r)-b)/w)),1)

print(f"True wind speed= {w}") print(f"True wind direction= {h}")