Esempio n. 1
0
def test_data(configs):
  in_channel = configs["params"]["in_channels"]
  out_channel = configs["params"]["out_channels"]
  encoder_feats = configs["params"]["encoder"]
  decoder_feats = configs["params"]["decoder"]
  model_path = configs["path"]["model"]

  hourglass = Hourglass(in_channel, out_channel, encoder_feats, decoder_feats)
  hourglass.load_state_dict(torch.load(model_path))
  hourglass.eval()

  transform = torchvision.transforms.Compose([torchvision.transforms.ToTensor()])
  test_dataset = torchvision.datasets.MNIST(
      root="~/torch_datasets", train=False, transform=transform, download=True
  )
  test_loader = torch.utils.data.DataLoader(
      test_dataset, batch_size=32, shuffle=False, num_workers=4
  )

  for img,_ in test_loader:
    print(img.size())
    out = hourglass(img)
    print(out.size())
    for i in range(out.size(0)):
      show(img[i].squeeze().detach())
      show(out[i].squeeze().detach())
    e()
 def Harry_Potter():
     while True:
         harry_potter = {
             "name":
             "Harry James Potter",
             "species":
             "human",
             "gender":
             "male",
             "house":
             "Gryffindor",
             "bloodStatus":
             "half-blood",
             "eyeColor":
             "green",
             "age":
             "40",
             "parents":
             "Lily and James Potter",
             "funFact":
             "Voldemort tried to kill him as a child, but didn't succeed. That left a scar on his forhead."
         }
         q2 = input(
             "What would you like to learn about Harry Potter? [N]ame, [S]pecies [G]ender, [H]ouse, [B]lood Status, [E]ye Color, [P]arents, [A]ge or [F]un fact\n\n"
         )
         if q2 == 'N' or q2 == 'n':
             print(f'His full name is {harry_potter["name"]}')
         elif q2 == 'S':
             print(f'His species is {harry_potter["species"]}')
         elif q2 == 'G':
             print(f'His gender is {harry_potter["gender"]}')
         elif q2 == 'H':
             print(f'He is in {harry_potter["house"]}')
         elif q2 == 'B':
             print(f'He is {harry_potter["bloodStatus"]}')
         elif q2 == 'E':
             print(f'He has {harry_potter["eyeColor"]} eyes.')
         elif q2 == 'P':
             print(f'His parents are {harry_potter["parents"]}')
         elif q2 == 'F':
             print(
                 f'Here is a fun fact about him: {harry_potter["funFact"]}')
         else:
             print(f'He is {harry_potter["age"]} years old.')
         q3 = input(
             "Would you like to learn more about Harry Potter, about other characters, or exit this dictionary? [L]earn more about Harry Potter, [O]ther characters, or [E]xit "
         )
         if q3 == 'L' or q3 == 'l':
             print("Okay, loading, please be patient...")
         elif q3 == 'O' or q3 == 'o':
             print(
                 "Loading, please wait (it may take up to 7 seconds to load..."
             )
             intro()
             intro()
         else:
             print("Bye, thanks for using this!")
             e(0)
def Luna_Lovegood():
    status = True
    while status:
        correct = 0
        wrong = 0
        Luna_Lovegood = {}
        q1 = input(f"{name.title()}, what is Luna's species? ")
        if q1 == 'human' or 'Human':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["species"] = q1
        q2 = input(f"{name.title()}, what is Luna's gender? ")
        if q2 == 'female' or 'Female':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["gender"] = q2
        q3 = input(f"{name.title()}, what is Luna's house? ")
        if q3 == 'ravenclaw' or 'Ravenclaw':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["house"] = q3
        q4 = input(f"{name.title()}, what is Luna's blood status? ")
        if q4 == 'half-blood' or 'Half blood' or 'Half Blood' or 'Half-blood' or 'Half-Blood':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["blood status"] = q4
        q5 = input(f"{name.title()}, what is Luna's age? ")
        if q5 == '39' or 'thirty-nine' or 'thirty nine':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["age"] = q5
        q6 = input(f"{name.title()}, what are Luna's parents names? ")
        if q6 == 'pandora and xenophilius lovegood' or 'Pandora and Xenophilius Lovegood' or 'Xenophilius and Pandora Lovegood' or 'xenophilius and pandora lovegood':
            correct += 1
        else:
            wrong += 1
        Luna_Lovegood["parents"] = q6
        for key, value in Luna_Lovegood.items():
            print(f'Here is what you put in for {key}: {value}')
        q7 = input('Is this correct? ')
        if q7 == 'yes' or 'Yes' or 'y' or 'Y':
            print('Good, here are your results:')
            print(f'You got {correct} out of 6')
        else:
            print('Try again, start over this quiz.')
        q8 = input(
            'It is the end, would you like to learn about these characters (no quiz)? y/n '
        )
        if q8 == 'y' or 'Y':
            dictionary()
        else:
            e('Okay, exiting.')
 def Luna_Lovegood():
     while True:
         luna_lovegood = {
             "name":
             "Luna Lovegood",
             "species":
             "human",
             "gender":
             "female",
             "house":
             "ravenclaw",
             "bloodStatus":
             "half-blood",
             "eyeColor":
             "blue",
             "age":
             "39",
             "parents":
             "Pandora and Xenophilius Lovegood",
             "funFact":
             "Her father was trying to create the lost diadom of ravenclaw"
         }
         q1 = input(
             "What do you want to learn about her? [N]ame, [S]pecies, [G]ender, [H]ouse, [B]lood status, [E]ye color, [A]ge, [P]arents, or [F]un fact?"
         )
         if q1 == 'N':
             print(f'Her name is {luna_lovegood["name"]}')
         elif q1 == 'S':
             print(f'Her species is {luna_lovegood["species"]}')
         elif q1 == 'G':
             print(f'Her gender is {luna_lovegood["gender"]}')
         elif q1 == 'H':
             print(f'Her house is {luna_lovegood["house"]}')
         elif q1 == 'B':
             print(f'Her blood status is {luna_lovegood["bloodStatus"]}')
         elif q1 == 'E':
             print(f'Her eye color is {luna_lovegood["eyeColor"]}')
         elif q1 == 'A':
             print(f'She is {luna_lovegood["age"]} years old.')
         elif q1 == 'P':
             print(f'Her parents are: {luna_lovegood["parents"]}')
         else:
             print(
                 f'Here is a fun fact about her: {luna_lovegood["funFact"]}'
             )
         q2 = input(
             'Would you like to [L]earn more about her, [O]ther characters, or [E]xit'
         )
         if q2 == 'L':
             print("Okay, be patient.")
         elif q2 == 'O':
             print("Okay, be patient.")
             intro()
         else:
             print("Okay, be patient")
             e(0)
Esempio n. 5
0
def useless():
    """Prints Useless."""
    global alien

    native = True
    number = (80 + 4) / 2
    floater = 3.61 - 2
    count = 10
    no = "No"

    count **= 2
    ll = lisztList()

    while number <= 8 ** 2:
        for i in ll:
            print i
            count += 1
        
        try:
           choice = int(raw_input("Choose > "))
        except ValueError:
           print "No! It has to be a number!"
           e()
        finally:
           pass

        if choice == 0 and number > floater:
           pass
        elif choice == 1 or number < floater:
           native = not True
           count *= 2
        elif choice == 2 and number >= floater:
           alien = False
           count /= 3
           break
        elif choice % 2 > 0 or number <= floater:
           print "\a%s, not that\b one.\f" % no
           continue
        else:
           count -= 1
           native = False
           alien = False
        number = number * floater
   
    del number

    if native == True and alien == True:
        count //= 4
        return "\n    Peace and Friendship:\r %d" % count
    elif native == True or alien != False:
        count %= 5
        return "\a\tWe gonna\v have problems.\\\\ %i" % count
    else:
        print "\"Useless!\" %r" % count
        print '\'Useless!\''
        e(None)
    def Ron_Weasley():
        while True:
            ron_weasley = {
                "name":
                "Ronald Bilius Weasley",
                "species":
                "human",
                "gender":
                "male",
                "house":
                "Gryffindor",
                "bloodStatus":
                "Pure-blood",
                "eyeColor":
                "blue",
                "age":
                "40",
                "parents":
                "Molly and Arthur Weasley",
                "funFact":
                "Despite the fact that he doesn't speak parseltounge, he did it to open the chamber of secrets to get a basilisk fang in book 7."
            }

            q1 = input(
                "What would you like to learn about Ron Weasley? [N]ame, [S]pecies [G]ender, [H]ouse, [B]lood Status, [E]ye Color, [P]arents, [A]ge or [F]un fact\n\n"
            )
            if q1 == 'N':
                print(f'His full name is {ron_weasley["name"]}')
            elif q1 == 'S':
                print(f'His species is {ron_weasley["species"]}')
            elif q1 == 'G':
                print(f'His gender is {ron_weasley["gender"]}')
            elif q1 == 'H':
                print(f'His house is {ron_weasley["house"]}')
            elif q1 == 'B':
                print(f'His blood status is {ron_weasley["bloodStatus"]}')
            elif q1 == 'E':
                print(f'His eye color is {ron_weasley["eyeColor"]}')
            elif q1 == 'P':
                print(f'His parents are {ron_weasley["parents"]}')
            elif q1 == 'A':
                print(f'He is {ron_weasley["age"]} years old.')
            elif q1 == 'F':
                print(
                    f'Here is a fun fact about him: {ron_weasley["funFact"]}')
            q2 = input(
                "What would you like to do? [L]earn more about Ron, [Le]arn about other characters, or [E]xit this dictionary?"
            )
            if q2 == 'L':
                print('Loading, this may take up to 7 seconds.')
            elif q2 == 'Le' or q2 == 'le' or q2 == 'LE':
                print("Loading, this may take up to 7 seconds.")
                intro()
                intro()
            else:
                e(0)
 def Hermione_Granger():
     while True:
         hermione_granger = {
             "name":
             "Hermione Jean Granger",
             "species":
             "human",
             "gender":
             "female",
             "house":
             "gryffindor",
             "bloodStatus":
             "Muggle-born",
             "eyeColor":
             "brown",
             "age":
             "41",
             "parents":
             "Mrs. and Mr. Granger (names unknown)",
             "funFact":
             "Despite that she is very smart, the Sorting hat put her in Gryffindor"
         }
         q1 = input(
             "What would you like to learn about Hermione Granger? [N]ame, [S]pecies, [G]ender, [H]ouse, [B]lood status, [E]ye color, [P]arents, [A]ge or [F]un fact\n\n"
         )
         if q1 == 'N':
             print(f'Her full name is {hermione_granger["name"]}')
         elif q1 == 'S':
             print(f'Her species is {hermione_granger["species"]}')
         elif q1 == 'G':
             print(f'Her gender is {hermione_granger["gender"]}')
         elif q1 == 'H':
             print(f'Her house is {hermione_granger["house"]}')
         elif q1 == 'B':
             print(f'Her blood status is {hermione_granger["bloodStatus"]}')
         elif q1 == 'E':
             print(f'Her eye color is {hermione_granger["eyeColor"]}')
         elif q1 == 'P':
             print(f'Her parents are {hermione_granger["parents"]}')
         elif q1 == 'A':
             print(f'She is {hermione_granger["age"]} years old.')
         else:
             print(
                 f'Here is a fun fact about her: {hermione_granger["funFact"]}'
             )
         q2 = input(
             "What would you like to do? [L]earn more about her, [O]ther characters, or [E]xit the dictionary"
         )
         if q2 == 'L':
             print("Loading, be patient...")
         elif q2 == 'O':
             print("Loading, be patient...")
             intro()
         else:
             print("Okay, exiting...")
             e(0)
Esempio n. 8
0
def test_gan(config):
    generator = Generator(config['hypers']['z'])
    generator.load(config['paths']['model'])
    noise = torch.randn(9, config['hypers']['z'])
    plot_2d(generator, noise)
    e()
    img = generator(noise).view(9, 28, 28)
    plt.imshow(img[0].detach())
    plt.savefig('./test.png')
    plt.show()
def Voldemort():
    while True:
        Voldemort = {
            "name":
            "Tom Marvolo Riddle Jr.",
            "species":
            "human (split soul)",
            "gender":
            "male",
            "house":
            "Slytherin",
            "bloodStatus":
            "half-blood",
            "eyeColor":
            "red (formerly brown)",
            "yrs_alive":
            "71 at death",
            "parents":
            "Merope and Tom Riddle Sr.",
            "funFact":
            "He and Harry's wand have a phoenix feather from the same phoenix"
        }
        q1 = input(
            "What would you like to learn about Voldemort? [N]ame, [S]pecies, [G]ender, [H]ouse, [B]lood status, [E]ye color, [A]ge, [P]arents, or [F]un fact "
        )
        if q1 == 'N':
            print(f'His name is {Voldemort["name"]}')
        elif q1 == 'S':
            print(f'His species is {Voldemort["species"]}')
        elif q1 == 'G':
            print(f'His gender is {Voldemort["gender"]}')
        elif q1 == 'H':
            print(f'His house is {Voldemort["house"]}')
        elif q1 == 'B':
            print(f'His blood status is {Voldemort["bloodStatus"]}')
        elif q1 == 'E':
            print(f'His eye color is {Voldemort["eyeColor"]}')
        elif q1 == 'A':
            print(f'He is {Voldemort["yrs_alive"]} years old.')
        elif q1 == 'P':
            print(f'His parents are {Voldemort["parents"]}')
        else:
            print(f'Here is a fun fact about him: {Voldemort["funFact"]}')
        q2 = input(
            "What would you like to do? [L]earn more about him, [O]ther characters, or [E]xit the dictionary"
        )
        if q2 == 'L':
            print("Loading, be patient...")

        elif q2 == 'O':
            print("Loading, be patient...")
            intro()
        else:
            print("Okay, exiting...")
            e(0)
Esempio n. 10
0
 def forward(self, x):
     heatmap = self.hourglass(x)
     heatmap_viz = heatmap.clone()
     img_shape = heatmap.size()
     heatmap = heatmap.view(img_shape[0], img_shape[1], img_shape[2], -1)
     heatmap = F.softmax(heatmap / 0.1, dim=3)
     heatmap = heatmap.view(*img_shape)
     kp_array = kp_mean_var(heatmap, x)
     # util.viz_kps(heatmap_viz, x, kp_array["mean"])
     util.visualize_kps(x, kp_array)
     e()
     return kp_array
 def Cedric_Diggory():
     while True:
         cedric_diggory = {
             "name": "Cedric Diggory",
             "species": "human",
             "gender": "male",
             "house": "Hufflepuff",
             "bloodStatus": "Unknown (not Muggle-born)",
             "eyeColor": "gray",
             "yrs_alive": "17",
             "parents": "Amos and Mrs. Diggory",
             "funFact": "He was killed as a 'spare'"
         }
         q1 = input(
             'What do you want to learn about him? [N]ame, [S]pecies, [G]ender, [H]ouse, [B]lood status, [E]ye color, [Y]ears alive, [P]arents, or [F]un fact? '
         )
         if q1 == 'N' or q1 == 'n':
             print(f'His name is {cedric_diggory["name"]}')
         elif q1 == 'S' or 's':
             print(f'His species is {cedric_diggory["species"]}')
         elif q1 == 'G' or q1 == 'g':
             print(f'His gender is {cedric_diggory["gender"]}')
         elif q1 == 'H':
             print(f'His house is {cedric_diggory["house"]}')
         elif q1 == 'B':
             print(f'His blood status is {cedric_diggory["bloodStatus"]}')
         elif q1 == 'E':
             print(f'His eye color is {cedric_diggory["eyeColor"]}')
         elif q1 == 'A':
             print(
                 f'He was {cedric_diggory["yrs_alive"]} years old (when he died)'
             )
         elif q1 == 'P':
             print(f'His parents are {cedric_diggory["parents"]}')
         else:
             print(
                 f'Here is a fun fact about him: {cedric_diggory["funFact"]}'
             )
         q2 = input(
             "What would you like to do? [L]earn more about him, [O]ther characters, or [E]xit the dictionary"
         )
         if q2 == 'L':
             print("Loading, be patient...")
         elif q2 == 'O':
             print("Loading, be patient...")
             intro()
         else:
             print("Okay, exiting...")
             e(0)
Esempio n. 12
0
def main():
	clear()
	print(logoseeker)
	wtf = input("seeter > ")
	if wtf == "1" or wtf == "01":
		install()
		clear()
		main()
	elif wtf == "2" or wtf == "02":
		remove()
		clear()
		main()
	elif wtf == "3" or wtf == "03":
		print("\nExiting...")
		t(1)
		e()
	else:
		print("\nERROR: Check your command!")
		t(1)
		clear()
		main()
Esempio n. 13
0
def train_data(configs):
    root_folder = configs['paths']['input']
    img_size = configs['hypers']["common"]['size']
    ext = configs['params']['ext']
    b_size = configs['hypers']["common"]['batch_size']

    dataset = DataClass(root_folder, img_size, ext)
    dataloader = DataLoader(dataset, batch_size=b_size, shuffle=False)

    in_features = configs["hypers"]["common"]["in_channel"]
    out_features = configs["hypers"]["common"]["out_channel"]
    max_features = configs["hypers"]["common"]["max_features"]
    num_block = configs["hypers"]["common"]["num_blocks"]
    block_expansion = configs["hypers"]["common"]["block_expansion"]
    kp_variance = configs["hypers"]["common"]["kp_variance"]
    mask_embedding_params = configs["hypers"]["generator_params"][
        "mask_embedding_params"]
    norm_const = configs["hypers"]["generator_params"]["norm_const"]
    num_group_blocks = configs["hypers"]["generator_params"][
        "num_group_blocks"]
    use_mask = configs["hypers"]["generator_params"]["use_mask"]
    use_correction = configs["hypers"]["generator_params"]["use_correction"]

    kp_detector = KeyPointDetector(in_features, out_features, max_features,
                                   num_block, block_expansion)
    generator = Generator(in_features, out_features, max_features, num_block, block_expansion,\
      kp_variance, norm_const, num_group_blocks, use_mask, use_correction, **mask_embedding_params)

    for b, img in enumerate(dataloader, 0):
        img_size = img.size()
        img = img.view(-1, img_size[2], img_size[3], img_size[4],
                       img_size[5]).permute(0, 2, 1, 3, 4)
        source_img = img[:, :, 0].unsqueeze(2)
        driving_img = img[:, :, 1].unsqueeze(2)

        kp = kp_detector(img)
        kp_split = split_kp(kp)
        predicted = generator(source_img, kp_split["kp_source"],
                              kp_split["kp_driving"])
        e()
def hermione_granger():
    status = True
    while status:
        correct = 0
        wrong = 0
        hermione_granger = {}
        q1 = input(f'{name.title()}, what is Hermione' + "'s full name? ")
        if q1 == 'Hermione Jean Granger' or 'Hermione jean granger' or 'hermione jean granger':
            correct += 1
        else:
            wrong += 1
        hermione_granger["name"] = q1
        q2 = input(f"{name.title()}, what is Hermione's species? ")
        if q2 == 'human' or 'Human':
            correct += 1
        else:
            wrong += 1
        hermione_granger["species"] = q2
        q3 = input(f"{name.title()}, what is Hermione's gender? ")
        if q3 == 'female' or 'Female' or 'girl' or 'Girl' or 'woman' or 'Woman':
            correct += 1
        else:
            wrong += 1
        hermione_granger["gender"] = q3
        q4 = input(f"{name}, what is Hermione's house? ")
        if q4 == 'gryffindor' or 'Gryffindor':
            correct += 1
        else:
            wrong += 1
        hermione_granger["house"] = q4
        q5 = input(f"{name.title()}, what is Hermione's blood status? ")
        if q5 == 'Muggle Born' or 'muggle born' or 'Muggle born' or 'muggle-born' or 'Muggle-Born' or 'Muggle-born':
            correct += 1
        elif q5 == 'mudblood' or 'Mudblood' or 'mud blood' or 'Mud Blood' or 'Mud blood':
            print(f"{name}, that is very offensive, you may not continue!".
                  upper())
            e(0)
        else:
            wrong += 1
        hermione_granger["blood status"] = q5
        q6 = input(f"{name.title()}, what is Hermione's eye color? ")
        if q6 == 'brown' or 'Brown':
            correct += 1
        else:
            wrong += 1
        hermione_granger["eye color"] = q6
        q7 = input(f"{name.title()}, what is Hermione's age? ")
        if q7 == '41' or 'forty one' or 'Forty one' or 'Forty One' or 'forty-one' or 'Forty-one' or 'Forty-One':
            correct += 1
        else:
            wrong += 1
        hermione_granger["age"] = q7
        print(
            f'{name.title()}, that was the last question. NOTE: Since Hermione'
            +
            "'s parent's names are unknown, I will not do a question on them.")
        print("Here is what you put in earlier:")
        for key, value in hermione_granger.items():
            print(f'\tHer {key} is {value}.\n')
        print(
            f'Here are your results:\nYou got {correct} right and {wrong} wrong out of 7.'
        )
        hermione_granger_correct_answers = {
            "name": "Hermione Jean Granger",
            "species": "human",
            "gender": "female",
            "house": "Gryffindor",
            "blood status": "muggle-born",
            "eye color": "brown",
            "age": "41"
        }
        print('Here are the correct answers:\n')
        for key, value in hermione_granger_correct_answers.items():
            print(f'\tHer {key} is {value}.\n')
        q10 = input(
            f"{name.title()}, what would you like to do? [D]o this quiz again, or [N]ext quiz? "
        )
        if q10 == 'N' or 'n':
            Voldemort()
Esempio n. 15
0
def run():
    #the function inits the whole game and runs its loop

    def finish_deal():
        draw_button.enabled = False
        pass_button.enabled = False
        double_button.enabled = False
        while croupier.points <= 21 and croupier.points < player.points:
            croupier.draw(cards)
            images.append(
                CardImg(screen, (len(croupier.hand) * 160 - 60,
                                 settings.screen_height - 500), (150, 200),
                        croupier.hand[-1]))
            for img in images:
                img.blitme()

    pygame.init()
    settings = Settings()

    screen = pygame.display.set_mode(
        (settings.screen_width, settings.screen_height))
    pygame.display.set_caption("Blackjack")

    screen.fill(settings.bg_color)
    images = []

    #declaring necessary objects
    place_bet_box = InputBox(screen, settings,
                             (100, settings.screen_height - 55),
                             settings.def_box_size)
    bet_label = Box(screen,
                    settings,
                    color=settings.bg_color,
                    enabled=True,
                    pos=(100, settings.screen_height - 90),
                    size=(150, 30),
                    text='Your bet:')
    place_bet_button = Button(screen,
                              settings, (220, settings.screen_height - 55),
                              settings.def_box_size,
                              text="Place bet")

    player = Player()
    croupier = Player()
    cards = Cards()

    balance_label = Box(screen,
                        settings,
                        color=settings.bg_color,
                        pos=(100, 50),
                        size=(200, 30),
                        text="Balance: " + str(player.balance))
    your_bet_label = Box(screen,
                         settings,
                         color=settings.bg_color,
                         pos=(100, 80),
                         size=(150, 30),
                         text="Your bet: ")
    win_loss_label = Box(screen,
                         settings,
                         color=settings.bg_color,
                         pos=(500, settings.screen_height / 2 + 30),
                         size=settings.def_box_size,
                         text='')
    your_cards_label = Box(screen,
                           settings,
                           color=settings.bg_color,
                           pos=(100, settings.screen_height / 2 + 60),
                           size=settings.def_box_size,
                           text='Your cards:')
    croupiers_cards_label = Box(screen,
                                settings,
                                color=settings.bg_color,
                                pos=(100, 150),
                                size=(200, 30),
                                text='Croupiers cards:')

    draw_button = Button(screen,
                         settings, (340, settings.screen_height - 55),
                         size=settings.def_box_size,
                         text='Draw')
    draw_button.color = settings.dr_button_color
    pass_button = Button(screen,
                         settings, (460, settings.screen_height - 55),
                         size=settings.def_box_size,
                         text='Pass')
    pass_button.color = settings.p_button_color
    double_button = Button(screen,
                           settings, (580, settings.screen_height - 55),
                           size=settings.def_box_size,
                           text='Double')
    double_button.color = settings.do_button_color

    place_bet_button.enabled = True

    def restart():
        pygame.display.flip()
        sleep(3)
        cards.shuffle()
        screen.fill(settings.bg_color)
        your_bet_label.update_text('Your bet:')
        win_loss_label.update_text('')
        balance_label.update_text("Balance: " + str(player.balance))
        player.hand = []
        croupier.hand = []
        player.points = croupier.points = 0
        place_bet_button.enabled = True

    while True:
        #the loop of the game

        bet_label.blitme()

        place_bet_box.blitme()

        place_bet_button.blitme()
        your_bet_label.blitme()
        balance_label.blitme()
        your_cards_label.blitme()
        croupiers_cards_label.blitme()

        draw_button.blitme()
        pass_button.blitme()
        double_button.blitme()

        win_loss_label.blitme()

        if player.points > 21:
            win_loss_label.update_text("You lose.")
            draw_button.enabled = False
            pass_button.enabled = False
            double_button.enabled = False
            images = []
            restart()

        elif croupier.points <= 21 and croupier.points > player.points:
            win_loss_label.update_text("You lose.")
            images = []
            restart()

        elif croupier.points > 21:
            player.balance += player.bet * 2
            win_loss_label.update_text("You win.")
            images = []
            restart()

        elif croupier.points == player.points != 0:
            player.balance += player.bet
            win_loss_label.update_text("That's a tie.")
            images = []
            restart()

        for event in pygame.event.get():

            place_bet_box.handle_event(event, settings.font)

            if draw_button.handle_event(event):
                player.draw(cards)
                images.append(
                    CardImg(screen, (len(images) * 160 + 100,
                                     settings.screen_height - 200), (150, 200),
                            player.hand[-1]))
                for img in images:
                    img.blitme()

            if double_button.handle_event(event):
                player.bet *= 2
                player.draw(cards)
                images.append(
                    CardImg(screen, (len(images) * 160 + 100,
                                     settings.screen_height - 200), (150, 200),
                            player.hand[-1]))
                for img in images:
                    img.blitme()
                your_bet_label.blitme()
                player.balance -= player.bet // 2
                balance_label.update_text("Balance: " + str(player.balance))
                your_bet_label.update_text("Your bet: " + str(player.bet))
                finish_deal()

            if pass_button.handle_event(event):
                finish_deal()

            if place_bet_button.handle_event(event):
                #checks if player has enough money to place a bet
                player.bet = int(place_bet_box.text)
                if player.bet <= player.balance and player.bet != 0:
                    player.balance -= player.bet
                    place_bet_button.enabled = False
                    your_bet_label.update_text("Your bet: " + str(player.bet))
                    draw_button.enabled = True
                    pass_button.enabled = True
                    double_button.enabled = True
                    balance_label.update_text("Balance: " +
                                              str(player.balance))

            if event.type == pygame.QUIT:
                e()

        pygame.display.flip()
Esempio n. 16
0
    if lCode == "en":
        cprint.info(
            "This is not fatal with English translations, we can ignore it.")
        ignore = input("Ignore? (Y/n): ").lower()
        if ignore[0] == "n":
            cprint.fatal("Abort.", interrupt=True)
        else:  #if user chooses to ignore
            cprint.info("Defaulting to YES.")
            logging.info("User ignored error!")

            def _(
                theEnglishString
            ):  #define a function that does nothing except give the value back so that NameErrors dont occur
                return theEnglishString
    else:
        e(1)
else:
    ignore = "undefined"
cprint.ok("Loading Palc files...\n")
lang_translations.install()
_ = lang_translations.gettext  #if both of these fail we're screwed anyway, and im NOT adding the ignoring support here
#import func and parsefunc
logging.info("Attempting to import parsefunc.py..")
try:
    from parsefunc import *
except Exception as e:
    logging.critical("Could not access file parsefunc.py (%s)" % e)
    cprint.fatal(_(
        "I can't load the file parsefunc.py. This file is necessary for proper function of the Software."
    ),
                 interrupt=True)
Esempio n. 17
0
def palc():
    if sys.stdin.isatty(
    ):  #https://stackoverflow.com/questions/13442574/how-do-i-determine-if-sys-stdin-is-redirected-from-a-file-vs-piped-from-another
        pressanykey(_("Press any key to continue..."))
        clearScreen()
    else:
        time.sleep(1)
#CALCULATION CHOICE
    calc = input(
        _("What calculation do you wish to do? (Type `?' for a list of commands)\nType: "
          ))
    logging.info("Got calc choice %s" % calc)
    calc = calc.lower()  #make variable "calc" lowercase
    #HELP
    if "?" in calc or _("help") in calc:
        logging.info("User needed help")
        misc.h()
#TAX
    elif _("tax") in calc:
        misc.showUserWhatIThink(_("calculate tax"))
        Tax.taxCalc()
#SQUARE
    elif _("sq") in calc or "[]" in calc:
        misc.showUserWhatIThink(_("square a number"))
        n = int(input(_("Number to square? ")))
        cprint.info(n * n)
        logging.info("User squared number %s got result %s" % (n, (n * n)))
#DIVISION
    elif "/" in calc or _("div") in calc:
        misc.showUserWhatIThink(_("divide a number"))
        theBasics.division()
#SUBTRACTION
    elif "-" in calc or _("sub") in calc or _("min") in calc:
        misc.showUserWhatIThink(_("subtract a number from a number"))
        theBasics.subtraction()
#ADDITION
    elif "+" in calc or _("add") in calc or _("plus") in calc:
        misc.showUserWhatIThink(_("add two numbers"))
        theBasics.addition()
    elif lCode == "fr":
        if "ajoute" in calc:
            misc.showUserWhatIThink(_("add two numbers"))
            theBasics.addition()
#MODULO
    elif "%" in calc:
        print(
            _("1 - Find the remainder of two numbers after division\n\
2 - Use the percentage calculator.\n\
Anything else - Back to menu."))
        pOrMod = input(_("Type: "))
        if pOrMod == "1":
            theBasics.mod()
        elif pOrMod == "2":
            Percentage.chooseOneTwo()
        else:
            cprint.info(_("going back."))
            logging.info("going back. (%s)" % pOrMod)
    elif _("mod") in calc:
        misc.showUserWhatIThink(
            _("find the remainder of two numbers after division"))
        theBasics.mod()
#AREA
    elif _("area") in calc or "#" in calc:
        misc.showUserWhatIThink(_("calculate area"))
        misc.area()
#VOLUME
    elif _("vol") in calc:
        misc.showUserWhatIThink(_("use the volume calculator"))
        misc.vol()
#CUBE
    elif "{}" in calc or _("cube") in calc:
        misc.showUserWhatIThink(_("cube a number"))
        cubedNumber = int(input(_("\nType the number to be cubed: ")))
        print()
        cprint.info(cubedNumber**3)  #Manually cube number
        logging.info("User cubed number %s got result %s" % (cubedNumber,
                                                             (cubedNumber**3)))
        print()
#SPINNER
    elif _("spin") in calc or _("spinner") in calc or _("roulette") in calc:
        misc.showUserWhatIThink(_("spin a spinner"))
        misc.spinner()
#EXIT
    elif _("quit") in calc or _("exit") in calc:
        misc.showUserWhatIThink(_("quit"))
        logging.info("User exited using `quit' command")
        e()
#EXPONENTS
    elif _("power") in calc or _("ex") in calc:
        misc.showUserWhatIThink(_("use the exponent function"))
        rootsAndTheOtherOne.powerful()
    elif "^" in calc:  #IDEA SOURCE: 3N4N's (first) Pull Request on the original repo
        misc.showUserWhatIThink(_("use the exponent function"))
        rootsAndTheOtherOne.powerful()
#MULTIPLICATION
    elif "*" in calc or "x" in calc or _("multi") in calc:
        misc.showUserWhatIThink(_("multiply a number"))
        theBasics.multiplication()
#CUBE TWICE
    elif "{2}" in calc:
        cprint.err(
            _("The \"cube twice\" feature was discontinued as it was pointless. Sorry for the inconvenience."
              ))
        logging.error(
            "User attempted to use cube twice function but it's gone")
#ROOTS
    elif _("root") in calc:
        misc.showUserWhatIThink(
            _("use the root function (opposite of exponents)"))
        root = input(
            _("Square root or cube root? (square/cube)\nType: ")).lower()
        if _("square") in root:
            rootsAndTheOtherOne.sqroot()
        elif _("cube") in root:
            rootsAndTheOtherOne.curoot()
        else:
            cprint.err(
                _("Currently I don't support the root you chose. Hopefully this will change :D"
                  ))
            logging.error("User used non-existent root (%s)" % root)
#NUMBER SYSTEMS
    elif _("base") in calc:
        misc.showUserWhatIThink(_("convert number systems"))
        misc.base()
#ORD
    elif _("ord") in calc:
        misc.showUserWhatIThink(_("ord a character"))
        result = str(ord(input(_("Type in the character to ord: "))))
        logging.info("User ord'ed to get result %s" % result)
        cprint.info(_("The result is: \n%s" % result))
#LOGARITHM
    elif _("log") in calc:
        misc.showUserWhatIThink(_("use the logarithm function"))
        misc.logarithm()
#MEMORY
    elif _("mem") in calc:
        misc.showUserWhatIThink(_("use the memory function"))
        memOrRecall = input(
            _("Would you like to set the memory or recall? (set / recall)\nType: "
              ))
        if _("set") in memOrRecall.lower():
            misc.remember()
        elif _("recall") in memOrRecall.lower():
            misc.readMyMemory()
        else:
            cprint.err(_("You did not type an answer.\nAbort."))
            logging.error(
                "User didn't type an answer in MEM function (typed %s)" %
                memOrRecall)
#FIBONACCI
    elif _("fib") in calc:
        misc.showUserWhatIThink(_("use the fibonacci calculator"))
        cprint.ok(_("Starting fibonacci sequence. Please wait."))
        misc.fib()
#PERCENTAGE
    elif _("percent"
           ) in calc:  #SOURCE: https://stackoverflow.com/a/5998010/9654083
        misc.showUserWhatIThink(_("use the percentage function"))
        Percentage.chooseOneTwo()
#INTEREST
    elif _("interest") in calc:
        misc.showUserWhatIThink(_("use the interest calculator"))
        misc.calculateInterest()
#TEMPERATURE
    elif _("temperature") in calc:
        misc.showUserWhatIThink(_("use the temperature converter"))
        Temperature.tempCalc()
#CONVERSIONS
    elif _("conver") in calc:
        logging.info("use the converter functions")
        misc.showUserWhatIThink(_("use the converter functions"))
        conversion = int(
            input(
                _("1 - Convert temperature units\n2 - Convert bits and bytes and kilobytes and mebibytes and stuff\nType: "
                  )))
        if conversion == 1:
            Temperature.tempCalc()
        else:
            cprint.err(_("Not developed yet, but maybe soon! :D"))
            logging.info(
                "User typed %s into conver functions but Non Existent." %
                conversion)
#OLD
    elif "raise" in calc:
        cprint.info(
            _("This feature has been disabled due to security reasons."))
#EASTER EGG!
    elif "=" in calc:
        misc.showUserWhatIThink(_("use the e a s t e r e g g"))
        number = int(input(_("\nType in a number: ")))
        if number == 42:
            cprint.info(
                _("=42 -- the answer to life, the universe, and everything"))
            logging.info("User got the easter egg")
        else:
            cprint.info(_("Calculating..."))
            time.sleep(3)
            cprint.err(_("ERROR: Too big of a number, timed out!"))
            logging.info("User used the `=' feature for number %s" % number)


#OTHERWISE
    elif calc == "":
        logging.error("User attempted to type nothing as a command")
        cprint.err(_("I can't heeeeaaaarrrrrr yooooouuuuuuuu"))
    elif calc == " ":
        logging.error("user said nothing")
        cprint.err(_("You speak quietly"))
    else:
        logging.error("User typed an invalid command (%s)" % calc)
        cprint.err(
            _("\n"
              "I don't understand your request. Here are the currently supported calculations:\n"
              "%s\n"
              "Sorry for the inconvenience\n") % misc.hText)
Esempio n. 18
0
 recovery = file
 file = file.strip('.txt').replace('/', '\\')
 for_target = file.split('\\')[-1]
 # target1 = target.strip('.txt').split('\\')[-1]+'__'
 target1 = target.strip('.txt') + '__'
 # print(target1)
 filename_k = target1 + for_target + '_k.txt'
 # print(filename_k)
 filename_percent = target1 + for_target + '_percent.txt'
 # print(filename_percent)
 filename_a = target1 + for_target + '_a.txt'
 # print(filename_a)
 filename_n = target1 + for_target + '_n.txt'
 # print(filename_n)
 if len(file) == 0:
     e()
 file += '.txt'
 recovery += '.txt' if '.txt' not in recovery else ''
 try:
     with open(filename_k, 'r') as f:
         k = f.read()
 except FileNotFoundError:
     k = None
 k = 1 if k is None else (int(k) if k != '' else 1)
 try:
     with open(filename_percent, 'r') as f:
         percents = f.read()
         content = percents.split('\n')
         percent1 = content[0]
         percent = content[1]
 except FileNotFoundError:
Esempio n. 19
0
def palc():
    while True:
        print(_("Press any key to continue..."), end="", flush=True)
        if _IS_WINDOWS:
            msvcrt.getch()
        else:
            fd = sys.stdin.fileno()
            settings = termios.tcgetattr(fd)
            try:
                tty.setraw(sys.stdin.fileno())
                sys.stdin.read(1)
            finally:
                termios.tcsetattr(fd, termios.TCSADRAIN, settings)
        print(chr(27) + '[2j'
              )  #First attempt at clearing the screen with ANSI escape codes.
        print('\033c'
              )  #Second attempt at clearing the screen with ANSI escape codes.
        print('\x1bc'
              )  #Third attempt at clearing the screen with ANSI escape codes.
        #CALCULATION CHOICE
        calc = input(
            _("What calculation do you wish to do? (Type `?' for a list of commands)\nType: "
              ))
        logging.info("Got calc choice %s" % calc)
        calc = calc.lower()  #make variable "calc" lowercase
        #HELP
        if "?" in calc:
            logging.info("User needed help")
            h()
        elif _("help") in calc:
            logging.info("User needed help")
            h()
#TAX
        elif _("tax") in calc:
            showUserWhatIThink(_("calculate tax"))
            taxCalc()
#SQUARE
        elif _("sq") in calc:
            showUserWhatIThink(_("square a number"))
            n = int(input(_("Number to square? ")))
            cprint.info(n * n)
            logging.info("User squared number %s got result %s" % (n, (n * n)))
        elif "[]" in calc:
            showUserWhatIThink(_("square a number"))
            n = int(input(_("Number to square? ")))
            logging.info("User squared number %s got result %s" % (n, (n * n)))
            cprint.info(n * n)
#DIVISION
        elif "/" in calc:
            showUserWhatIThink(_("divide a number"))
            div()
        elif "div" in calc:
            showUserWhatIThink(_("divide a number"))
            div()
#SUBTRACTION
        elif "-" in calc:
            showUserWhatIThink(_("subtract a number from a number"))
            sub()
        elif _("sub") in calc:
            showUserWhatIThink(_("subtract a number from a number"))
            sub()
        elif "min" in calc:
            showUserWhatIThink(_("subtract a number from a number"))
            sub()
#ADDITION
        elif "+" in calc:
            showUserWhatIThink(_("add two numbers"))
            add()
        elif "add" in calc:
            showUserWhatIThink(_("add two numbers"))
            add()
        elif "plus" in calc:
            showUserWhatIThink(_("add two numbers"))
            add()
#MODULO
        elif "%" in calc:
            showUserWhatIThink(
                _("find the remainder of two numbers after division"))
            mod()
        elif "mod" in calc:
            showUserWhatIThink(
                _("find the remainder of two numbers after division"))
            mod()
#AREA
        elif _("area") in calc:
            showUserWhatIThink(_("calculate area"))
            area()
        elif "#" in calc:
            showUserWhatIThink(_("calculate area"))
            area()
#VOLUME
        elif _("vol") in calc:
            showUserWhatIThink(_("use the volume calculator"))
            uc()
#CUBE
        elif "{}" in calc:
            showUserWhatIThink(_("cube a number"))
            cubedNumber = int(input(_("\nType the number to be cubed: ")))
            print()
            cprint.info(cubedNumber**3)  #Manually cube number
            logging.info("User cubed number %s got result %s" %
                         (cubedNumber, (cubedNumber**3)))
            print()
        elif _("cube") in calc:
            showUserWhatIThink(_("cube a number"))
            cubedNumber = int(input(_("\nType the number to be cubed: ")))
            print()
            cprint.info(cubedNumber**3)  #Manually cube number
            logging.info("User cubed number %s got result %s" %
                         (cubedNumber, (cubedNumber**3)))
            print()
#EXIT
        elif _("quit") in calc:
            showUserWhatIThink(_("quit"))
            logging.info("User exited using `quit' command")
            e()
        elif "exit" in calc:
            showUserWhatIThink(_("exit"))
            logging.info("User exited using `exit' command")
            e()
#MULTIPLICATION
        elif "*" in calc:
            showUserWhatIThink(_("multiply a number"))
            multi()
        elif "x" in calc:
            showUserWhatIThink(_("multiply a number"))
            multi()
        elif "multi" in calc:
            showUserWhatIThink(_("multiply a number"))
            multi()
#EXPONENTS
        elif "power" in calc:
            showUserWhatIThink(_("use the exponent function"))
            origin = float(input(_("Original number?")))
            ex = float(input(_("Exponent? ")))
            cprint.info(origin**ex)
            logging.info("User exponented number %s with %s, getting %s" %
                         (origin, ex, (origin**ex)))
        elif "ex" in calc:
            showUserWhatIThink(_("use the exponent function"))
            origin = float(input(_("Original number?")))
            ex = float(input(_("Exponent? ")))
            cprint.info("=%s" % origin**ex)
            logging.info("User exponented number %s with %s, getting %s" %
                         (origin, ex, (origin**ex)))
#CUBE TWICE
        elif "{2}" in calc:
            cprint.err(_("The \" CUBE TWICE \" feature was discontinued."))
            logging.error(
                "User attempted to use cube twice function but it's discontinued"
            )
#ROOTS
        elif _("root") in calc:
            showUserWhatIThink(
                _("use the root function (opposite of exponents)"))
            root = input(_("Square root or cube root? (square/cube)\nType: "))
            root = root.lower()
            if _("square") in root:
                num = input(_("Number to be rooted?"))
                cprint.info(_("That equals.....\n", num**0.5))
                logging.info("user sqrooted number %s" % (num**0.5))
            elif "cube" in root:
                cu()
            else:
                cprint.err(
                    _("Currently I don't support the root you chose. Hopefully this will change :)"
                      ))
                logging.error("User used non-existent root (%s)" % root)
#EASTER EGG!
        elif "=" in calc:
            showUserWhatIThink(
                _("use the equals function (completely useless)"))
            number = int(input(_("\nType in a number: ")))
            if number == 42:
                cprint.info(
                    _("=42 -- the answer to life, the universe, and everything"
                      ))
                logging.info("User got the easter egg")
            else:
                cprint.err(_("Do you really need a calculator for this?"))
                logging.info("User used the `=' feature for number %s" %
                             number)
#NUMBER SYSTEMS
        elif "base" in calc:
            showUserWhatIThink(_("convert number systems"))
            base()
#ORD
        elif "ord" in calc:
            showUserWhatIThink(_("ord a number"))
            result = str(ord(int(input(_("Type in the number to ord: ")))))
            logging.info("User ord'ed to get result %s" % result)
            cprint.info("= %s" % result)
#LOGARITHM
        elif _("log") in calc:
            showUserWhatIThink(_("use the logarithm function"))
            log()
#MEMORY
        elif "mem" in calc:
            showUserWhatIThink(_("use the memory function"))
            memOrRecall = input(
                _("Would you like to set the memory or recall? (set / recall)\nType: "
                  ))
            if _("set") in memOrRecall.lower():
                remember()
            elif _("recall") in memOrRecall.lower():
                readMyMemory()
            else:
                cprint.err(_("You did not type an answer.\nAbort."))
                logging.error(
                    "User didn't type an answer in MEM function (typed %s)" %
                    memOrRecall)
#FIBONACCI
        elif "fib" in calc:
            showUserWhatIThink(_("use the fibonacci calculator"))
            cprint.ok(_("Starting fibonacci sequence. Please wait."))
            fib()
#PERCENTAGE
        elif _("percent"
               ) in calc:  #SOURCE: https://stackoverflow.com/a/5998010/9654083
            showUserWhatIThink(_("use the percentage function"))
            whichOne = int(
                input(
                    _('''1 - Calculate "What is x% of y?"
2 - Convert a number to percentage.
Type: ''')))
            if whichOne == 1:
                whatIsPercent()
            elif whichOne == 2:
                getPercentageRN()
            else:
                cprint.err(_("You didn't type a valid answer. Abort."))
                logging.info(
                    "User did not answer correct percentage interpretation (typed %s)"
                    % whichOne)
#INTEREST
        elif _("interest") in calc:
            showUserWhatIThink(_("use the interest calculator"))
            calculateInterest()
#TEMPERATURE
        elif "temperature" in calc:
            showUserWhatIThink(_("use the temperature converter"))
            tempCalc()
#CONVERSIONS
        elif "conver" in calc:
            showUserWhatIThink(_("use the converter functions"))
            conversion = int(input(_("1 - Convert temperature units\nType: ")))
            if conversion == 1:
                tempCalc()


#OTHERWISE
        elif calc == "":
            logging.error("User attempted to type nothing as a command")
            cprint.err(_("Type something!"))
        elif calc is None:
            logging.error("User attempted to type nothing as a command")
            cprint.err(_("Type something!"))
        else:
            logging.error("User typed an invalid command (%s)" % calc)
            cprint.err(
                _('''
I don't understand your request. Here are the currently supported calculations:
multiplication, division, subtraction, addition, modulo, square, area, volume, cube, power, root, ord, fibonacci, logarithm, memory, percentage calculator, interest calculator, temperature, and base. Sorry for the inconvenience
'''))
Esempio n. 20
0
        call(['sample', '-dict', sample_dict, '-case', path, '-time', '150'],
             stdout=devnull,
             stderr=devnull)
    else:
        raise RuntimeError('Unknown dialect')
    print('done.')
    stdout.flush()
    devnull.close()


def _run():
    from os import getcwd
    from sys import stdout
    import os.path
    sample_dict = os.path.join(getcwd(), 'sampleDict')

    version = os.path.basename(os.getenv('WM_PROJECT_DIR')).split('-').pop()

    for path in _foam_cases('.'):
        print('Post-processing {0}'.format(path))
        stdout.flush()
        _run_sample(path, sample_dict, dialect=version)
        _run_pimple_log_stats(path)
        _plot_flow_field(path)
    return 0


if __name__ == '__main__':
    from sys import exit as e
    e(_run())
Esempio n. 21
0
def add_lms(frame, in_fpath, cnt, lm_cols, op_fpath, arr):
    for i in zip(arr[cnt, :68], arr[cnt, 68:]):
        cv2.circle(frame, (i[0], i[1]), 2, (0, 255, 0), 2)
    util.show(frame)
    e()
Esempio n. 22
0
# IMPORT MODULES
from sys import exit as e
import six
# DECLARE CONSTANTS
VERSION = "N/A"  #version of Todolist
# detect python version
if six.PY2:  #source https://stackoverflow.com/a/43481041/9654083
    e("Unsupported Python Version")
else:
    print("Welcome to Todolist!")
Esempio n. 23
0
    elif dialect == '2.4.x':
        call(['sample', '-dict', sample_dict, '-case', path, '-time', '150'],
             stdout=devnull, stderr=devnull)
    else:
        raise RuntimeError('Unknown dialect')
    print('done.')
    stdout.flush()
    devnull.close()


def _run():
    from os import getcwd
    from sys import stdout
    import os.path
    sample_dict = os.path.join(getcwd(), 'sampleDict')

    version = os.path.basename(os.getenv('WM_PROJECT_DIR')).split('-').pop()

    for path in _foam_cases('.'):
        print('Post-processing {0}'.format(path))
        stdout.flush()
        _run_sample(path, sample_dict, dialect=version)
        _run_pimple_log_stats(path)
        _plot_flow_field(path)
    return 0


if __name__ == '__main__':
    from sys import exit as e
    e(_run())
Esempio n. 24
0
def palc():
    while True:
        #HELP
        if "?" in calc:
            logging.info("User needed help")
            h()
        elif "help" in calc:
            logging.info("User needed help")
            h()
#TAX
        elif "tax" in calc:
            taxCalc()
#MULTIPLICATION
        elif "*" in calc:
            multi()
        elif "x" in calc:
            multi()
#SQUARE
        elif "sq" in calc:
            n = int(input(_("Number? ")))
            cprint.info(n * n)
            logging.info(("User squared number ", n, " got result ", (n * n)))
        elif "[]" in calc:
            n = int(input(_("Number? ")))
            logging.info(("User squared number ", n, " got result ", (n * n)))
            cprint.info(n * n)
#DIVISION
        elif "/" in calc:
            div()
        elif "div" in calc:
            div()
#SUBTRACTION
        elif "-" in calc:
            sub()
        elif "sub" in calc:
            sub()
        elif "min" in calc:
            sub()
#ADDITION
        elif "+" in calc:
            add()
        elif "add" in calc:
            add()
#MODULO
        elif "%" in calc:
            mod()
        elif "mod" in calc:
            mod()
#AREA
        elif "ar" in calc:
            area()
        elif "#" in calc:
            area()
        elif "area" in calc:
            area()
#VOLUME
        elif "vol" in calc:
            uc()
#CUBE
        elif "{}" in calc:
            cubedNumber = int(input("\nType the number to be cubed: "))
            print()
            cprint.info(cubedNumber**3)  #Manually cube number
            logging.info(("User cubed number ", cubedNumber, " got result ",
                          (cubedNumber**3)))
            print()
#EXIT
        elif "quit" in calc:
            logging.info("User exited using `quit' command")
            e()
#EXPONENTS
        elif "power" in calc:
            origin = int(input("Original number?"))
            ex = int(input("Exponent? "))
            cprint.info(origin**ex)
            logging.info(("User exponented number ", origin, " with ", ex,
                          "getting ", (origin**ex)))
        elif "ex" in calc:
            origin = int(input("Original number?"))
            ex = int(input("Exponent? "))
            print(origin**ex)
            logging.info(("User exponented number ", origin, " with ", ex,
                          "getting ", (origin**ex)))
#CUBE TWICE
        elif "{2}" in calc:
            cprint.err(_("That feature was discontinued."))
#ROOTS
        elif "root" in calc:
            root = input("Square root or cube root?(square/cube)")
            root = root.lower()
            if "square" in root:
                num = input("Number to be rooted?")
                cprint.info(_("That equals.....\n", num**0.5))
                logging.info(("user sqrooted number ", (num**0.5)))
            elif "cube" in root:
                cu()
            else:
                print(
                    _("Currently I don't support the root you chose. Hopefully this will change :)"
                      ))
#EASTER EGG!
        elif "=" in calc:
            print()
            number = int(input("Type in a number: "))
            if number == 42:
                cprint.info(
                    _("=42 -- the answer to life, the universe, and everything"
                      ))
                logging.info("User got the easter egg")
            else:
                cprint.info("=" + number)
                logging.info("User used the `=' feature for number ", number)
#NUMBER SYSTEMS
        elif "base" in calc:
            base()
#ORD
        elif "ord" in calc:
            logging.info(("User ord'ed to get result ", result))
            result = str(ord(int(input(_("Type in the number to ord: ")))))
            cprint.info("=", result)
#LOGARITHM
        elif "log" in calc:
            log()
#MEMORY
        elif "mem" in calc:
            memOrRecall = input(
                "Would you like to set the memory or recall? (set / recall)\nType: "
            )
            if memOrRecall.lower() in "set":
                remember()
            elif memOrRecall.lower() in "recall":
                readMyMemory()
            else:
                cprint.err(_("You did not type an answer.\nAbort."))
                logging.error("User didn't type an answer in MEM function")
#FIBONACCI
        elif "fib" in calc:
            cprint.ok(_("Starting fibonacci sequence. Please wait."))
            fib()
#PERCENTAGE
        elif "percent" in calc:  #SOURCE: https://stackoverflow.com/a/5998010/9654083
            whichOne = int(
                input(
                    _('''1 - Calculate "What is x% of y?"
2 - Convert a number to percentage.
Type: ''')))
            if whichOne == 1:
                whatIsPercent()
            elif whichOne == 2:
                getPercentageRN()
            else:
                cprint.err(_("You didn't type a valid answer. Abort."))
#INTEREST
        elif "interest" in calc:
            calculateInterest()


#OTHERWISE
        elif calc == "":
            logging.error("User attempted to type nothing as a command")
            print(_("Type something!"))
        elif calc is None:
            logging.error("User attempted to type nothing as a command")
            print(_("Type something!"))
        else:
            logging.error("User typed an invalid command")
            print(
                _('''
            I don't understand your request. Here are the currently supported calculations:
            * or x; / or div; -, min, or sub; + or add; % or mod (modulo); sq or [] (square); ar or # (area); vol (volume); {} (cube); power (exponents/power); root (roots); = (equals); fib (fibonacci) log (logarithm); mem (memory); percent (calculate percentage); interest (interest calculator); and base (convert number system). Sorry for the inconvenience
            '''))