コード例 #1
0
ファイル: main.py プロジェクト: tyjeon/OgameTools
def main():
    with requests.Session() as s:
        server_address = login_ogame.login_ogame(s)

        while True:
            choice = input("Espionage : 1 \n"
                           "Mail To Csv : 2 \n"
                           "GalaxyTool : 3 \n"
                           "Exit : Else \n")

            try:
                choice = int(choice)
            except:
                continue

            if choice == 1:
                espionage.espionage(s, server_address)
            elif choice == 2:
                mail_to_csv.mail_to_csv(s, server_address)
            elif choice == 3:
                galaxy_tool.galaxy_tool(s, server_address)
            elif choice == 4:
                target_type = input("입력")
                amount = input("숫자 입력")
                invest.invest(s, target_type, amount, server_address)
            elif choice == 5:
                recommend_next_investment.recommend_next_investment(
                    s, server_address)
            else:
                break
コード例 #2
0
def main():
    # the program is written by Lei Yang (ly888)
    # the main function to calculate and plot daily return.
    # if the user input is not valid, the program will let the user to input again until valid or enter quit
    positions = input(
        "Enter a list of the number of shares to buy in parallel: e.g. 1,10,100,1000 or stop this process by entering quit \n"
    )
    positions_split = positions.split(",")
    # justify if the input value is valid
    flag = justify(positions_split)
    # if the user input quit, the program will stop. if the user input invalid value, the program will ask the user to input again
    while (positions != 'quit' and flag == 1):
        positions = input(
            "The last input is not valid. Please enter a list of the number of shares to buy in parallel: e.g. 1,10,100,1000 or stop this process by entering quit \n"
        )
        if (positions == 'quit'):
            break
        positions_split = positions.split(",")
        # justify if the input value is valid
        flag = justify(positions_split)
    if (positions != 'quit'):
        flag = 0
        num_trials = input(
            "How many times to randomly repeat the test? Or stop this process by entering quit \n"
        )
        # justify if the input value is valid
        if num_trials.isdigit() == False:
            flag = 1
        # if the user input quit, the program will stop. if the user input invalid value, the program will ask the user to input again
        while (num_trials != 'quit' and flag == 1):
            flag = 0
            num_trials = input(
                "The last input is not valid. How many times to randomly repeat the test? Or stop this process by entering quit \n"
            )
            # justify if the input value is valid
            if num_trials.isdigit() == False:
                flag = 1
            if (num_trials == 'quit'):
                break
    # if all the input are valid, the program will calculate the results and plot
    if (positions != 'quit' and num_trials != 'quit'):
        positions_list = [int(position) for position in positions_split]
        outcome = invest(positions_list, int(num_trials))
        outcome.invest_sub()
コード例 #3
0
ファイル: assignment8.py プロジェクト: ds-ga-1007/assignment8
def main():
    # the program is written by Lei Yang (ly888)
    # the main function to calculate and plot daily return. 
    # if the user input is not valid, the program will let the user to input again until valid or enter quit
    positions = input("Enter a list of the number of shares to buy in parallel: e.g. 1,10,100,1000 or stop this process by entering quit \n")
    positions_split = positions.split(",");
    # justify if the input value is valid
    flag=justify(positions_split);
    # if the user input quit, the program will stop. if the user input invalid value, the program will ask the user to input again
    while(positions != 'quit' and flag==1):
        positions=input("The last input is not valid. Please enter a list of the number of shares to buy in parallel: e.g. 1,10,100,1000 or stop this process by entering quit \n")
        if(positions =='quit'):
            break;
        positions_split = positions.split(",");
        # justify if the input value is valid
        flag=justify(positions_split);
    if(positions != 'quit'):  
        flag=0;
        num_trials = input("How many times to randomly repeat the test? Or stop this process by entering quit \n");
        # justify if the input value is valid
        if num_trials.isdigit()==False:
            flag=1;
        # if the user input quit, the program will stop. if the user input invalid value, the program will ask the user to input again
        while(num_trials != 'quit' and flag==1):
            flag=0;
            num_trials = input("The last input is not valid. How many times to randomly repeat the test? Or stop this process by entering quit \n");
            # justify if the input value is valid
            if num_trials.isdigit()==False:
                flag=1;
            if(num_trials == 'quit'):
                break;
    # if all the input are valid, the program will calculate the results and plot
    if(positions!='quit' and num_trials !='quit'):
        positions_list = [int(position) for position in positions_split];
        outcome = invest(positions_list, int(num_trials));
        outcome.invest_sub();
コード例 #4
0
ファイル: test.py プロジェクト: lampard8888/assignment8
def read_result(positions, num_trials):
    invest(positions, num_trials).invest_sub()

    with open('results.txt', 'r') as string:
        read_result = string.read()
    return read_result
コード例 #5
0
ファイル: unit_tests.py プロジェクト: ds-ga-1007/assignment8
 def test_invest(self):
     self.assertTrue(v.invest(self.test_investment) >= 0 and v.invest(self.test_investment) <= 2000)
コード例 #6
0
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  8 17:44:49 2019

@author: xJ0T3
"""

from invest import invest

test_list = {
    (1000, 10, 2): 1210,
    (5000, 1.10, 20): 6222,
    (3500, 0.9, 30): 4579
}

if __name__ == '__main__':
    for test_case, result in test_list.items():
        val = invest(*test_case)
        if val == result:
            print('Test case: {}\tOK'.format(test_case))
        else:
            print(
                'Test case: {}\tNOK, risultato atteso {}, risultato fornito {}'
                .format(test_case, result, val))
コード例 #7
0
ファイル: test.py プロジェクト: ds-ga-1007/assignment8
def read_result(positions, num_trials):
    invest(positions, num_trials).invest_sub()
    
    with open('results.txt','r') as string:
        read_result = string.read()
    return read_result
コード例 #8
0
ファイル: unit_tests.py プロジェクト: ds-ga-1007/assignment8
 def test_invest(self):
     self.assertTrue(v.invest(self.test_investment) >= 0 and v.invest(self.test_investment) <= 2000)