Пример #1
0
def shortestDistance(x1, y1, x2, y2):

    try:
        post_data = {
            'x1': x1,
            'x2': x2,
            'y1': y1,
            'y2': y2,
            'timestamp':
            'Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.now())
        }
        #Insert into Entries database
        databaseNeeds.insertEntries(post_data)
        sDist = math.sqrt(((float(x2) - float(x1)) * (float(x2) - float(x1))) +
                          ((float(y2) - float(y1)) * (float(y2) - float(y1))))
        print('Shortest distance is: ' + str(sDist) + '\n')
        post_data = {
            'Shortest_Distance': sDist,
            'timestamp':
            'Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.now())
        }
        databaseNeeds.insertResults(post_data)
    except ValueError:
        print('Error - incorrect data type used')
        pickAFunc()
Пример #2
0
def retirement(age, annualSalary, percentSaved, retirementSaveGoal):
    # print("")
    try:
        yearLeft = 0;
        amountTotal = 0;
        age = int(age);
        post_data = {
            'age': age,
            'annualSalary': annualSalary,
            'percentSaved': percentSaved,
            'retirementSaveGoal': retirementSaveGoal,
            'timestamp': 'Timestamp: {:%Y-%m-%d %H:%M:%S}'.format(datetime.now())

        }
        databaseNeeds.insertEntries(post_data)
        retirementSaveGoal = int(retirementSaveGoal)

        amount = int(annualSalary) * (float(percentSaved) / 100);
        amountT = amount * 0.35;

        while amountTotal < retirementSaveGoal and age < 100:
            yearLeft = yearLeft + 1;
            age = age + 1;
            if age == 100:
                print("Dead, you didn't make the goal")
                return "Dead"

            amountTotal = amountTotal +amountT + amount;
            # print(amountTotal)
            # print("Your age "+ str(age))
        print("Goal amount will be reached at " + str(age))
        databaseNeeds.insertResults(post_data)
        return age

    except ValueError:
        print("Invalid Type")
        raise ValueError("Invalid arguments.")
Пример #3
0
 def test_short_insert_result(self):
     self.assertFalse(databaseNeeds.insertResults({}))