Beispiel #1
0
def get_tolerance():
    response_tol = pyip.inputYesNo(f"\nSoll eine Bin-Toleranz abweichend von (+/-) 2.5 % verwendet werden? (yes/no) \n") =="yes"
    if response_tol==True:
        tolerance = pyip.inputNum(f"\nEnter the percent")/100
    else:
        tolerance = 2.5/100
    return tolerance
Beispiel #2
0
def main():
    print()
    print()
    print("#############################")
    print("###     Binning tools     ###")
    print("#############################")
    print()
    print("Willkommen zu den Jens Tools")
    print(f"Folgende Tools sind bisher im Programm:\n ")
    tools = {1 : "Fivebin", 9 : "Beende das Programm"}

    choice = True
    while choice == True:
        for key in tools:
            print(f'[{key}] - {tools[key]}')
        choice = pyip.inputNum(f"\nWelches Tool moechtest du verwenden?\n")

        if choice==1:
            choice = fivebin.main()
        elif choice==9:
            choice = False
        else:
            print(f"Ich konnte das Programm nicht finden \n")
            continue
    print(f"\n Auf wiedersehen!")
    return False
Beispiel #3
0
    def get_naki(self, action_list):
        (naki_options_str, naki_huros,
         naki_choices) = self.parse_naki_options(action_list)

        selected_naki = int(
            pyinput.inputChoice(
                naki_choices,
                prompt=f"""Please select naki type using number:
{naki_options_str}""",
                blank=True))

        if selected_naki == 6:
            return Naki.NONE, None

        possible_huro_opt = naki_huros[selected_naki]
        possible_huro_str = ""
        for i, huro in enumerate(possible_huro_opt):
            huro_str = "".join([unicode_block[h.index] for h in huro])
            possible_huro_str += f"{i}: {huro_str}\n"
        possible_huro_str += "6: Cancel\n"

        selected_huro = pyinput.inputNum(
            f"""Please select huro set using number:
{possible_huro_str}""",
            min=0,
            max=6)
        if selected_huro == 6:
            return Naki.NONE, None

        return selected_naki, possible_huro_opt[selected_huro]
Beispiel #4
0
def user_interface():
    print("-----")
    print("1. Copies")
    print("2. Fibonacci")
    print("3. Initials")
    print("4. Pascals")
    print("5. Decimal to Binary")
    print("6. Quit")
    response = pyip.inputNum("Enter the number of the program you would like to use! ")

    if response == 1:
        copies_interface()
    elif response == 2:
        fib_interface()
    elif response == 3:
        initials_interface()
    elif response == 4:
        pascal_interface()
    elif response == 5:
        to_binary_interface()
    elif response != 6:
        print("Invalid program number!")

    if response != 6:
        user_interface()
    else:
        print("Exiting..., thanks for playing!")
Beispiel #5
0
def main():
    print("##############################\n")
    print(f"\nWillkommen beim Fivebin Binning Tool\n")
    data, file_direction = get_data()
    tolerance = get_tolerance()
    print(f"\n Folgende Features sind verfuegbar:\n")
    features = {1: "Iteratives Binning (Empfohlen)", 2 : "Schnelles Binning", 3 : "Bestimmtes Binning" , 9 : "Tool beenden"}

    choice = True
    while choice == True:
        for feature in features:
            print(f'[{feature}] - {features[feature]}')
        choice = pyip.inputNum(f"\nWelches Feature moechtest du verwenden?\n")
        tic = time.clock()
        if choice==1:
            choice = mid_iterator(data, file_direction, tolerance, quick=False)
            print(f'Der Prozess dauerte {time.clock() - tic} Sekunden')
        elif choice == 2:
            choice = mid_iterator(data, file_direction, tolerance, quick=True)
            print(f'Der Prozess dauerte {time.clock() - tic} Sekunden')
        elif choice ==3:
            choice = specific_bin(data, file_direction, tolerance)
            print(f'Der Prozess dauerte {time.clock() - tic} Sekunden')

        elif choice==9:
            choice = False
        else:
            print(f"Ich konnte das Programm nicht finden \n")
            continue
        print("Was moechtest du nun machen?\n")
    return True
Beispiel #6
0
def coveredCall():
    # Stock price first, this is what the investor bought the stock at.

    purchasePrice = pyip.inputNum("Enter the price of the stock the investor paid: ")

    # Then we need the premium received for selling the call.

    premium = pyip.inputNum("Enter the premium the investor gained by selling the call: ")

    # Current price of the stock to determine the investor's position.

    stockPrice = pyip.inputNum("Enter the current price of the stock to determine the investor's yield: ")

    # And determine the yield currently as of now.

    coveredYield = premium + stockPrice - purchasePrice
    print('The investors current yield is ' + str(coveredYield) + '.')
Beispiel #7
0
def InputNonEven():
    #ERROR
    response = pyip.inputNum(blockRegexes=[r'[02468]$'])


#InputNumber()
#InputNumberRange()
#InputNonEven()
Beispiel #8
0
def getPlayerMove(board):
    # Let the player type in their move

    movePrompt = 'What is your next move? (1-9)\n'

    while True:
        move = pyip.inputNum(prompt=movePrompt, min=1, max=9)
        if isSpaceFree(board, move):
            return move
Beispiel #9
0
def specific_bin(data, file_direction, tolerance):
    stats = get_input_stats(data, tolerance=tolerance)
    max_dif = round(stats[3], 3)
    up_down_switch = int((len(np.array(data.messdaten)) / 5) / 2 - 1)


    while True:
        lower_thresh = pyip.inputNum(f"\nBitte gebe die untere Grenze an mit einem . als Dezimalseparator\n")
        upper_thresh = pyip.inputNum(f"\nBitte gebe die obere Grenze an mit einem . als Dezimalseparator\n")
        corridor = (lower_thresh, upper_thresh)
        print(f"\nDer eingegebene Korridor ist: {corridor}")
        response_corr = pyip.inputYesNo(f"\nStimmen die Werte? (yes/no) \n") == "yes"
        if response_corr is True:
            break
    Result = "none"
    for i in range(up_down_switch):
                result = create_new_list(get_bottom_up_bin_list(data, top=i, corridor=corridor))
                if min(np.array(result.bin_sum)) >= corridor[0] and max(np.array(result.bin_sum)) <= corridor[1] and max(np.array(result.bin_dif)) <= max_dif:
                    max_corridor_span = max(np.array(result.bin_sum)) - min(np.array(result.bin_sum))
                    Result = result

    if min(np.array(result.bin_sum)) >= corridor[0] and max(np.array(result.bin_sum)) <= corridor[1]:
        Result = result
        result_file_name = "Results/"+file_direction.replace(".csv", "_result.csv")
        Result.to_csv(result_file_name)

    if Result is "none":
        print("Fivebin konnte kein Ergebnis erzielen.")

    else:
        timestamp = get_time()
        result_file_name = "Results/"+timestamp+file_direction.replace(".csv", "_result.csv")
        Result.to_csv(result_file_name)

        print(f"\nDer Vorgang wurde beendet.")
        print(f'\nUntere Bin-Grenze= {min(np.array(Result.bin_sum))}')
        print(f'Obere Bin-Grenze= {max(np.array(Result.bin_sum))}')
        print(f'Maximale Varianz= {max(np.array(Result.bin_dif))}')

        print(f"\nDas Ergebnis wurde hier gespeichert: \n\n{result_file_name}\n")

    return True
Beispiel #10
0
def interval_timer():
    times = pyin.inputInt('How many sets do you want to do?')

    n = pyin.inputNum('after how many sets do you have to do this thing?')
    work3 = pyin.inputNum(
        'Enter the time you will do this thing  for in seconds.')

    work = pyin.inputNum('Enter the time you will work for in seconds.')
    notwork = pyin.inputNum(
        'Enter the time you will be on break for in seconds.')

    for i in range(1, times):
        if i % int(n + 1) == 0:
            print('break but fin')
            countdown(work3)
        else:
            print('work')
            countdown(work)
            print('break')
            countdown(notwork)
Beispiel #11
0
    def test_inputNum(self):
        self._test_inputNumTemplate(pyip.inputNum, '42', int)
        self._test_inputNumTemplate(pyip.inputNum, '42.0', float)

        # Test blockRegexes keyword arg, with a single regex.
        pauseThenType('42\n43\n')
        self.assertEqual(pyip.inputNum(blockRegexes=['42']), 43)
        self.assertEqual(getOut(), 'This response is invalid.\n')

        # Test blockRegexes keyword arg, with multiple regexes.
        pauseThenType('42\n44\n43\n')
        self.assertEqual(pyip.inputNum(blockRegexes=['42', r'[02468]$']), 43)
        self.assertEqual(getOut(), 'This response is invalid.\nThis response is invalid.\n')

        # Test postValidateApplyFunc keyword arg.
        # (The blocklist regex will block uppercase responses, but the
        # postValidateApplyFunc will convert it to uppercase.)
        pauseThenType('42\n41\n')
        self.assertEqual(pyip.inputNum(blockRegexes=['[02468]$'], postValidateApplyFunc=lambda x: x+1), 42)
        self.assertEqual(getOut(), 'This response is invalid.\n')
Beispiel #12
0
def playerMove():
    run = True
    while run:
        move = pyip.inputNum('Please select a position to place an \'X\'' \
       ' (1-9): ',min = 1, max = 9)

        if spaceIsFree(move):
            run = False
            insertLetter('X', move)
        else:
            print('Sorry, this space is occupied!')
Beispiel #13
0
def main():
    while(True):
        action = input("waiting for input...")
        if action == 'buy':
            amount = inp.inputNum("amount? (in USD) $")
            coin = input("symbol? ")
            inv.buy_in_USD(amount, inv.get_gmt_time(), str.upper(coin))
        elif action == 'sell':
            amount = inp.inputNum("amount? ")
            coin = input("symbol? ")
            inv.sell_sell_sell(amount, inv.get_gmt_time(), str.upper(coin))
        elif action == 'report':
            report(input("type? "))
        elif action == 'restart':
            inv.reset_investment_tables()
        elif action == 'restart coins':
            inv.reset_coin_tables()
        elif action == 'help':
            help()
        elif action == 'exit':
            break
Beispiel #14
0
def human_move():
    while True:
        # box = int(input("Select a box: "))
        box = pyip.inputNum('Select a box:', min=1, max=9)
        if box not in range(1, 10):
            print('Box not available')
        else:
            if matrix[box - 1] == ' ':
                matrix[box - 1] = human
                break
            else:
                print('Box not available')
class CHOOSE:
    base_input = pyip.inputNum(f"{Fore.LIGHTRED_EX}Base{Fore.RESET}: ")
    exp_input = pyip.inputNum(f"{Fore.LIGHTRED_EX}Exponent{Fore.RESET}: ",min=0)
    choose = input("STEPS - [ power_s1,power_s2,power_s3 ] : ")

    def __init__(self):
        if self.choose.casefold() == "power_s1":
            print()
            print(f"{Fore.LIGHTMAGENTA_EX}[*] Note - You will get an error here, because of infinte recursion"
                  "RecursionError: maximum recursion depth exceeded")
            time.sleep(2)
            print()
            print(PowerOfNum.power_s1(PowerOfNum,self.base_input,self.exp_input))
            print("hwll")
        elif self.choose.casefold() == "power_s2":
            print(PowerOfNum.power_s2(PowerOfNum,self.base_input,self.exp_input))

        elif self.choose.casefold() == "power_s3":
            print(PowerOfNum.power_s3(PowerOfNum,self.base_input,self.exp_input))
        else:
            print(f"{Fore.BLUE}choose one of in (power_s1,power_s2,power_s3)")
Beispiel #16
0
    def check_off(self):
        """
        Record the date and time in the DB tracking table when
        the user enters the habit id to mark it as done.
        """
        # Clean up the console
        self.clear_console()
        # Prints the name of the application and instructions to the main menu
        self.back_to_menu_info()
        print("""
                            CHECK A HABIT OFF
            ________________________________________________
                Check a habit off once you have done it
            ------------------------------------------------
            """)

        # A list of the existing information in the habit table of the DB
        habits_info = self.analytics.habits_table()
        # A list with all habit identifiers
        ids = self.analytics.get_all_ids(habits_info)

        while True:
            print("""
                Which habit do you want to check-off?
                """)
            # display a table with all the registered habits
            self.table_registered_habits()
            print('')
            id_n = pyip.inputNum("Choose the ID of your habit ")
            if id_n == 0:
                # back to the main menu
                self.run()
            elif id_n in ids:
                # Insert the day and time when the habit is checked-off
                self.analytics.insert_day(id_n)
                print("""
                 ------------------------------------------
                                Good job!
                             - {} - is done.
                 ------------------------------------------
                 """.format(
                    # Selects the habit name from the row that corresponds to the id
                    self.analytics.select_rows(habits_info, 0, id_n)[0][1]))
                if len(habits_info) > 1:
                    # Return to the main menu or check another habit
                    self.choice_stay_return('Check another habit off',
                                            self.check_off)
                else:
                    # Return to the main menu by selecting the number zero
                    self.return_menu()
            else:
                print("Please, choose an ID from the list")
Beispiel #17
0
def putCalc():
    optionPrice = pyip.inputNum("Enter the current price of the option contract: ")

    # Next we will get the price of the stock.

    stockPrice = pyip.inputNum("Enter the current price of the stock: ")

    # Maybe I also need the strike price of the option.

    strikePrice = pyip.inputNum("Enter the strike price associated with the contract: ")

    # Calculating the intrinsic value of the option.

    intrinsicValue = strikePrice - stockPrice

    print("The current intrinsic value is " + str(intrinsicValue) + ".")

    # Calculating the time value of the option

    timeValue = optionPrice - intrinsicValue

    print("The current time value is " + str(timeValue) + ".")
Beispiel #18
0
def main():
    while (user_input := input(mainMenu)) != "3":
        if user_input == "1":
            name = input("Enter your name: ").strip()
            deposit = pyinputplus.inputNum("Enter your initial deposit: ")
            savingacc1.createAccount(name, deposit)
        elif user_input == "2":
            name = input("Enter your name: ").strip()
            accountNumber = pyinputplus.inputNum("Enter your account number: ")
            if savingacc1.authenticate(name, accountNumber):
                while (user_input := input(accountMenu)) != "4":
                    if user_input == "1":
                        savingacc1.displayBalance()
                    elif user_input == "2":
                        amount = pyinputplus.inputNum(
                            "Enter withdrawal amount: ")
                        savingacc1.withdraw(amount)
                    elif user_input == "3":
                        amount = pyinputplus.inputNum("Enter deposit amount: ")
                        savingacc1.deposit(amount)
                    elif user_input == "5":
                        return
Beispiel #19
0
def get_data():
    files = [f for f in os.listdir("data") if isfile(join("data", f))]
    files_dic = {}
    print(f"Folgende Daten wurden gefunden:\n")
    for num, i in enumerate(files):
        files_dic[num+1] = i
        print(f"[{num+1}] - {i}")
    choice = pyip.inputNum(f"\nWaehle eine Datei aus. (Index)\n")
    direction = files_dic[choice]
    data = pd.read_csv("data/"+direction)
    data = data.sort_values(by=['messdaten'])

    return data, direction
Beispiel #20
0
def num_picker():
    full_num = generator()
    # variable to set length of final number
    # make option to set to max?
    range_choice = pyip.inputNum(max=len(full_num), prompt=(f'[?] How many digits do you want to generate? (Enter 0 for the maximum of {len(full_num)}): '))
    if range_choice == 0:
        range_choice = len(full_num)
    # flag to enable formatting for the final number
    format_num = pyip.inputYesNo(prompt=('[?] Do you want to use decimal separators? (e.g. The commas in: 1,234,567,890) [Y/N]: '))
    if format_num == 'yes':
        formatted_num = f'{int(full_num[0:range_choice]):,}'
        print(formatted_num)
    else:
        print(full_num[0:range_choice])
Beispiel #21
0
def timer():

    s = pyin.inputYesNo(
        'Do you know the time in seconds you want to exercise for')
    if s == 'yes':
        t = pyin.inputNum(
            'Enter the time in seconds you want the timer to go for')
    else:
        hours = pyin.inputInt(
            'Enter the amount of hours you will be working for')
        mins = pyin.inputInt(
            'Enter the amount of minutes you will be working for')
        t = seconds(hours, mins)
    countdown(t)
Beispiel #22
0
 def return_menu(self):
     """
     Return to the main menu by selecting the key with
     the number zero.
     """
     while True:
         number = pyip.inputNum("0. Back to the main menu: ")
         if number == 0:
             # Clean up the console
             self.clear_console()
             # back to the main menu
             self.run()
         else:
             print('Press the number zero to go back')
Beispiel #23
0
def getInputAmount(prompt: str = None,
                   minAmt: int = None,
                   maxAmt: int = None,
                   greaterThan: int = None,
                   lessThan: int = None):
    """
    Gets user input for an amount.

    Amount can be with decimal point or without decimal point.
    """
    return pyip.inputNum(prompt=prompt,
                         min=minAmt,
                         max=maxAmt,
                         greaterThan=greaterThan,
                         lessThan=lessThan)
Beispiel #24
0
def main():
    board = Board()
    count = 0

    while True:
        os.system('clear')
        board.pretty_print()

        if check_win(board):
            break

        print(f"Your turn (player X)")
        row = pyip.inputNum(prompt="Row #: ", min=1, max=3)
        col = pyip.inputNum(prompt="Column #: ", min=1, max=3)
        if make_move(board, 'X', int(row), int(col)):
            pass
        else:
            print("\nThat spot has already been taken.\nChoose another.\n")
            continue

        if check_win(board):
            break

        computer_turn(board)
Beispiel #25
0
def additiongame(num1, num2):

    num1 = random.randrange(1,10)
    num2 = random.randrange(1,10)
    global correct
    global incorrect

    answer = pyinputplus.inputNum('\n'f'{num1} + {num2} = ')
    x = num1 + num2

    if answer == x:
        print('Correct!')
        correct = correct + 1
    else:
        print(f'The answer was {x}')
        incorrect = incorrect + 1
Beispiel #26
0
    def actions_with_new_tile(self, action_list):
        options_str, min_act, max_act = self.parse_options(action_list)
        selected_action = pyinput.inputNum(
            "Please select action using number:\n" + options_str,
            min=min_act,
            max=max_act)

        selected_naki = None
        selected_huro = None
        if selected_action == Action.NAKI.value:
            selected_naki, selected_huro = self.get_naki(action_list)
            if selected_naki == Naki.NONE:
                selected_action = Action.NOACT.value

        naki = Naki(selected_naki) if selected_naki else None

        return Action(selected_action), naki, selected_huro
Beispiel #27
0
def menu():
    print("**********************")
    print("1. Wishes \n2. Song \n3. Exit")
    print("**********************")

    answer = pyip.inputNum("Please select menu item's number.")

    if answer == 1:
        print('The message will take a bit to display in full.')
        wishes()
    elif answer == 2:
        print("You will get a song.")
        song()
    elif answer == 3:
        exit()
    else:
        print("What?")
        menu()
Beispiel #28
0
    def select_discard(self, hand_tiles, kuikae_tiles, new_tile, is_riichi):
        if kuikae_tiles:
            # not allowed to choose from this list
            # TODO: now just hide from hand_representation,
            # need to change to something else if UI changes
            hand_tiles = [
                tile for tile in hand_tiles if tile not in kuikae_tiles
            ]
        if is_riichi and new_tile:
            hand_tiles = [new_tile]
        self.show_tiles(hand_tiles, discard=True)
        print("Please select the tile you want to discard:")
        discard = pyinput.inputNum("Discard tile No.: ",
                                   min=0,
                                   max=len(hand_tiles) - 1)
        discard_tile = hand_tiles[discard]
        print(f"Tile to discard: \n{unicode_block[discard_tile.index]}")

        return hand_tiles[discard]
Beispiel #29
0
    def gradeAssignment(self, points):
        grades = []
        # count is 1 because it marks the parts for each assignment
        count = 1
        # row set to 3 because its the row that we are gonna need first
        row = 3
        wb = openpyxl.load_workbook(self.excelFileName)
        sheet = wb["Sheet"]
        for point in points:
            intPoint = int(float(point))
            intPoint = int(float(point))
            """check to see if the grade is an actual grade. if not then ask again. do this with regex"""

            grade = pyip.inputNum(
                "please enter the grade for  part" + str(count) +
                ". The max score for this part is :" + str(point) + ".",
                min=0,
                max=intPoint)

            grades.append(grade)
            #set the grade of the correct section
            sheet["B" + str(row)] = int(grade)
            #print confirmation
            print("part " + str(count) + " set to " + str(grade))
            #if points are missed then ask for a reason
            if float(grade) != float(point):
                reason = pyip.inputStr(
                    "what is the reason for deducting points?")
                #insert the reason
                sheet["D" + str(row)] = reason
            #increment row and count
            row += 1
            count += 1
        total = 0
        for num in grades:
            total += int(num)
        #set the studentscores total to total
        self.total = total
        print("the total score for " + str(self.name) + " is " +
              str(self.total))
        wb.save(filename=folder + assignmentName + "Grade.xlsx")
        wb.close()
Beispiel #30
0
 def choice_stay_return(self, text, action):
     """
     Asks the user if he/she wants to return to
     the main menu or to perform the action
     indicated in number 1.
     """
     while True:
         print("""
               0. Back to the main menu
               1. {}
               """.format(text))
         choice = pyip.inputNum('Enter a number: ')
         if choice == 0:
             # Clean up the console
             self.clear_console()
             # Gives the options that can be selected in the menu
             self.run()
         elif choice == 1:
             action()
         else:
             print('Please, choose number 0 or 1')