Пример #1
0
 def update(self, R2, name):  # db에 답을 update시키는 함수
     if R2 == 1:
         conn = pymysql.connect(host='127.0.0.1',
                                user='******',
                                password='******',
                                db='javap',
                                charset='utf8')
         try:
             with conn.cursor() as cursor:
                 sql = "update pypeople set answer=answer+1 where person=%s"  # answer 기본값이 0이고, 만약 정답이 아니면 +1을 해주지 않는다.
                 cursor.execute(sql, name)
             conn.commit()
         finally:
             conn.close()
     q2.q2(name)
Пример #2
0
def q3():
    import pandas as pd
    from q2 import q2

    optimal = q2()
    lamda = optimal[1]

    data = pd.read_csv("new_data.csv")
    A = data.iloc[:, :].values

    reject_list = []
    for i in range(data.shape[0]):
        p = A[i, 4]
        for j in range(4):
            p -= lamda[j] * A[i, j]
        if p < 0:
            reject_list.append(i + 1)

    return (reject_list)
Пример #3
0
from q1 import q1
from q2 import q2
from q3 import q3
from q4 import q4
from q5 import q5

print "Question 1"
q1()
raw_input()

print "Question 2"
q2()

print "Question 3"
q3()

print "Question 4"
q4()

print "Question 5"
q5()
Пример #4
0
    tronco_points = np.array([
        [-1.5, -1.5, 0],
        [1.5, -1.5, 0],
        [1.5, 1.5, 0],
        [-1.5, 1.5, 0],
        [-0.65, -0.65, 2.5],
        [0.65, -0.65, 2.5],
        [0.65, 0.65, 2.5],
        [-0.65, 0.65, 2.5],
    ])

    # # PRIMEIRA QUESTÃO
    q1(cube_points, parallel_points, pyramid_points, tronco_points)

    # SEGUNDA QUESTÃO
    cube_points, parallel_points, pyramid_points, tronco_points = q2(
        cube_points, parallel_points, pyramid_points, tronco_points)
    # TERCEIRA QUESTÃO
    c_points, p_points = q3(copy(cube_points), copy(pyramid_points),
                            copy(parallel_points), copy(tronco_points),
                            np.array([3, -3, 3]), True)

    # QUARTA QUESTÃO
    q4(c_points, p_points, True)

    # OPCIONAL
    eyes = [np.array([i, -3, 3]) for i in np.arange(-2, 8, .5)]
    for i, eye in enumerate(eyes):
        # TERCEIRA QUESTÃO
        c_points, p_points = q3(copy(cube_points), copy(pyramid_points),
                                copy(parallel_points), copy(tronco_points),
                                eye)
Пример #5
0
def main():
    q1()
    q2()
    q3()
    q4()
Пример #6
0
def main():
    q1()
    q2()
    q3()
    q4()
Пример #7
0
def test_large_k():
    with pytest.raises(ValueError):
        q2([100, 1, 3000])
Пример #8
0
def test_example_1():
    assert q2([5, 2, 3]) == 'a:1,b:0,c:1'
Пример #9
0
def test_invalid_argument():
    with pytest.raises(TypeError):
        q2([5, 2, 'k'])
    with pytest.raises(ValueError):
        q2([5, 2])
Пример #10
0
def test_large_q():
    with pytest.raises(ValueError):
        q2([5, 2, 300])