示例#1
0
def perm(str):
    if len(str) < 2:
        help.helper("perm")
        return None
    total = int(str[1])
    pick = int(str[2])
    return fact(total) / fact(total - pick)
示例#2
0
def set(str):
	global vars
	if len(str) < 3:
		help.helper("set")
		return None
	if str[1] == 'x' or str[1] == 'y' or str[1] == 'a':
		print("Unable to set system variables")
	else:
		vars[str[1]] = float(str[2]) 
示例#3
0
def get(str):
	if len(str) < 2:
		help.helper("get")
		return None
	global vars
	try:
		return vars[str[1]]
	except:
		pass
示例#4
0
文件: vars.py 项目: zasapp/graphcalc
def set(str):
    global vars
    if len(str) < 3:
        help.helper("set")
        return None
    if str[1] == 'x' or str[1] == 'y' or str[1] == 'a':
        print("Unable to set system variables")
    else:
        vars[str[1]] = float(str[2])
示例#5
0
文件: vars.py 项目: zasapp/graphcalc
def get(str):
    if len(str) < 2:
        help.helper("get")
        return None
    global vars
    try:
        return vars[str[1]]
    except:
        pass
示例#6
0
def plot(args):
	if len(args) < 2:
		help.helper("points")
		return None
	xlist = []
	ylist = []
	for x in args[1:]:
		pt = x.split(",")
		if len(pt) > 1:
			xlist.append(pt[0])
			ylist.append(pt[1])
	plt.plot(xlist,ylist,'o')
示例#7
0
def plot(args):
    if len(args) < 2:
        help.helper("points")
        return None
    xlist = []
    ylist = []
    for x in args[1:]:
        pt = x.split(",")
        if len(pt) > 1:
            xlist.append(pt[0])
            ylist.append(pt[1])
    plt.plot(xlist, ylist, 'o')
示例#8
0
def intersect(args):
	if len(args) < 4:
		help.helper("intersect")
		return None
	eq1 = args[1]
	eq2 = args[2]
	rg = range(int(float(args[3])),int(float(args[4])))
	pts1x,pts1y = genpoints(eq1,rg,'x')
	pts2x,pts2y = genpoints(eq2,rg,'x')
	out = [] 
	for x in rg:
		if pts1x[x] == pts2x[x] and pts1y[x] == pts2y[x]:
			out.append((pts1x[x],pts1y[x]))
	for x in out:
		print("(%s)\n" % (x,))
示例#9
0
def sigma(args):
	# equation variable start end
	if len(args) < 4:
		help.helper("sigma")
		return None
	eq = args[1]
	var = args[2]
	start = int(float(args[3]))
	end = int(float(args[4]))
	result = 0
	
	# end+1 for inclusive range
	for x in range(start,end+1):
		result += parser.evaluate(eq,{var:x})
	print("%d" % result)
示例#10
0
def intersect(args):
    if len(args) < 4:
        help.helper("intersect")
        return None
    eq1 = args[1]
    eq2 = args[2]
    rg = range(int(float(args[3])), int(float(args[4])))
    pts1x, pts1y = genpoints(eq1, rg, 'x')
    pts2x, pts2y = genpoints(eq2, rg, 'x')
    out = []
    for x in rg:
        if pts1x[x] == pts2x[x] and pts1y[x] == pts2y[x]:
            out.append((pts1x[x], pts1y[x]))
    for x in out:
        print("(%s)\n" % (x, ))
示例#11
0
def stats(lst):
    if len(lst) < 2:
        help.helper("stats")
        return None
    list = []
    for x in lst[1:]:
        list.append(int(x))
    #print(list)
    st = {}
    try:
        st["mean"] = mean(list)
        st["standard deviation"] = stdev(list)
        st["median"] = median(list)
        st["mode"] = mode(list)
    except:
        pass
    for x, y in st.items():
        print("%s = %d" % (x, y))
示例#12
0
def stats(lst):
	if len(lst) < 2:
		help.helper("stats")
		return None
	list = []
	for x in lst[1:]:
		list.append(int(x))
	#print(list)
	st= {}
	try:
		st["mean"] = mean(list)
		st["standard deviation"] = stdev(list)
		st["median"] = median(list)
		st["mode"] = mode(list)
	except:
		pass
	for x,y in st.items():
		print("%s = %d" % (x,y))
示例#13
0
文件: graph.py 项目: zasapp/graphcalc
def graph(str):
    if len(str) < 4:
        help.helper("graph")
        return None
    global numfig
    try:
        plt.figure(int(str[5]))
    except:
        plt.figure(numfig)
        numfig += 1

    plt.title(str[2])
    plt.grid()
    start = int(float(str[3]))
    end = int(float(str[4]))
    rg = range(start, end)
    if str[1] == 'x':
        xeq(str[2], rg)
    elif str[1] == 'y':
        yeq(str[2], rg)
示例#14
0
def graph(str):
	if len(str) < 4:
		help.helper("graph")
		return None
	global numfig
	try:
		plt.figure(int(str[5]))
	except:
		plt.figure(numfig)
		numfig += 1

	plt.title(str[2])
	plt.grid()
	start = int(float(str[3]))
	end = int(float(str[4]))
	rg = range(start,end)
	if str[1] == 'x':
		xeq(str[2],rg)
	elif str[1] == 'y':
                yeq(str[2],rg)
示例#15
0
def combo(str):
    if len(str) < 2:
        help.helper("combo")
    total = int(str[1])
    pick = int(str[2])
    return fact(total) / (fact(pick) * fact(total - pick))