def main():
    """
	Creates a new password using random characters
	"""
    # Pool of characters that are drawn upon to create a password
    chars_vowels = "aeiouAEIUaeiu"
    all_chars = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
    chars_number = "0123456789"
    chars_symbol = "@#$!"
    # Referencing the strings above, 8 total characters are taken from the strings in a random
    # fashion, with this being done 10 total times
    play = 0
    my_tools.print_lines()
    print("\t\t\t\t\t\t\t", my_tools.PyColors.bold,
          my_tools.PyColors.Fg.light_yellow, my_tools.PyColors.Bg.dark_blue,
          "Password Generator", my_tools.PyColors.reset,
          "\n\n Below are 10 randomly generated passwords:\n")
    while play < 10:
        new_password = random.choice(chars_vowels)
        new_password += random.choice(all_chars)
        new_password += random.choice(chars_number)
        new_password += random.choice(chars_symbol)
        new_password += random.choice(chars_vowels)
        new_password += random.choice(all_chars)
        new_password += random.choice(chars_vowels)
        new_password += random.choice(chars_vowels)
        password_list = list(new_password)
        random.SystemRandom().shuffle(password_list)
        new_password = "".join(password_list)
        print(" " + new_password)
        play += 1
    input("\n\n Press enter to continue...").strip()
示例#2
0
def main():
	"""
	Program make a simple calculator
	"""
	while True:
		my_tools.print_lines()
		print(
			"\t\t\t\t\t\t\t\t ",
			my_tools.PyColors.bold,
			my_tools.PyColors.Fg.dark_green,
			"Calculator Module",
			my_tools.PyColors.reset
		)
		choice = input(
			"\n Select an operation:"
			"\n 1) Add"
			"\n 2) Subtract"
			"\n 3) Multiply"
			"\n 4) Divide"
			"\n 5) Return To Main Menu"
			"\n\n Please select from one of the options listed above (1-5): "
		).strip()

		# Check if choice is one of the four options
		if int(choice) in range(1, 5):
			num1 = input("\n Enter 1st number: ")
			num2 = input(" Enter 2nd number: ")

			my_calculator = Calculator(num1, num2)

			if choice == "1":
				my_calculator.add()
			elif choice == "2":
				my_calculator.subtract()
			elif choice == "3":
				my_calculator.multiply()
			elif choice == "4":
				my_calculator.divide()

			input("\n\n Press enter to continue...").strip()
			break

		# Returns to the previous menu
		elif choice == "5":
			break

		#
		else:
			print(
				"\n",
				my_tools.PyColors.bold,
				my_tools.PyColors.Fg.light_yellow,
				"Invalid input, please try again...",
				my_tools.PyColors.reset
			)
示例#3
0
def main():
    """
	Includes several games for fun, including coin flip and random number generator that both
	return random results
	"""
    while True:
        my_tools.print_lines()
        print("\n\t\t\t ", my_tools.PyColors.Bg.light_blue,
              "Random Number Generator", my_tools.PyColors.reset,
              "\n\n So you want a random number, in what range?")
        first_number = input(" Start of range: ").strip()
        second_number = input(" End of range: ").strip()
        random_result = random.randint(int(first_number), int(second_number))
        print("\n\n Your random number is: " + str(random_result) + "\n\n")
        choice = input(" Go again or return to previous menu? Y/N\n ").strip()
        if "y" in choice.lower():
            continue
        elif "n" in choice.lower():
            break
示例#4
0
def main():
    """
	Includes several games for fun, including coin flip and random number generator that both
	return random results
	"""
    while True:
        my_tools.print_lines()
        print("\n\t\t\t\t ", my_tools.PyColors.Bg.light_blue, "Coin Flip",
              my_tools.PyColors.reset, "\n\n Heads or Tails, call it...\n")
        input().strip()
        random_result = random.randint(1, 2)
        if random_result == 1:
            print(" HEADS!\n\n")
        elif random_result == 2:
            print(" TAILS!\n\n")
        choice = input(
            " Play again or return to previous menu? Y/N\n ").strip()
        if "y" in choice.lower():
            continue
        elif "n" in choice.lower():
            break
示例#5
0
def main():
	"""
	Main module for all others, presents menus in loops for easy end-user accessibility and
	re-usability.
	:return:
	:rtype:
	"""
	# Try statement for catching errors
	try:
		# Continuous while loop that keeps the program going indefinitely
		while True:
			# Prints a long yellow line to separate sections of the menu
			my_tools.print_lines()
			# Program's banner, containing the name, version and date
			print(
				"\t\t\t\t\t\t\t",
				my_tools.PyColors.bold,
				my_tools.PyColors.Fg.light_yellow,
				" <<< Dashboard >>>",
				my_tools.PyColors.reset,
				"\n\n\t\t\t\t\t",
				my_tools.PyColors.Fg.light_green,
				"  Project Version <|> Last Updated\n\t\t\t\t\t\t\t",
				"  0.0.5         12/05/2020",
				my_tools.PyColors.reset
			)

			# Presents the user with a menu of options to choose from
			first_choice = input(
				"\n 1) General"
				"\n 2) Game of Chance"
				"\n 3) Release Notes"
				"\n 4) Quit"
				"\n\n Please select from one of the options listed above (1-4): "
			).strip()

			#
			if first_choice == "1":
				while True:
					my_tools.print_lines()
					print(
						"\t\t\t\t\t\t\t\t ",
						my_tools.PyColors.bold,
						my_tools.PyColors.Fg.dark_green,
						"General Module",
						my_tools.PyColors.reset
					)

					second_choice = input(
						"\n 1) Password Generator"
						"\n 2) Coin Flip"
						"\n 3) Random Number Generator"
						"\n 4) Calculator"
						"\n 5) Return To Main Menu"
						"\n\n Please select from one of the options listed above (1-5): "
					).strip()

					#
					if second_choice == "1":
						password_generator.main()

					#
					elif second_choice == "2":
						coin_flip.main()

					#
					elif second_choice == "3":
						random_number.main()

					#
					elif second_choice == "4":
						calculator.main()

					# Returns the user to the main menu
					elif second_choice == "5":
						break

			#
			elif first_choice == "2":

				#
				while True:
					my_tools.print_lines()
					print(
						"\n\t\t\t ",
						my_tools.PyColors.Bg.light_blue,
						"Test 2 Module",
						my_tools.PyColors.reset
					)
					second_choice = input(
						"\n 1) Test 1"
						"\n 2) Test 2"
						"\n 3) About Module"
						"\n 4) Return To Main Menu"
						"\n\n Please select from one of the options listed above (1-4): "
					).strip()
					try:
						#
						if int(second_choice) in range(1, 3):
							# Test.Test(second_choice)
							pass

						#
						elif second_choice == "3":
							# Test.Test.about_module()
							pass

						# Returns to the previous menu
						elif second_choice == "4":
							break

					# Protects the program from erroneous data being entered
					except ValueError:
						continue

			# How to section on reporting any issues with this program
			elif first_choice == "3":
				my_tools.print_lines()
				print(
					"\n\t\t\t ",
					my_tools.PyColors.Bg.light_blue,
					"Version 0.0.0 Release Notes",
					my_tools.PyColors.reset,
					"\n\n New Features:"
					"\n"
				)
				input("\n\n Press enter to continue...").strip()
				continue

			# Enables to user to exit the program without a keyboard interrupt
			elif first_choice == "4":
				print("\n\n ...Exiting program\n\n")
				sys.exit(0)

	# Gracefully ends the program when the user hits the 'control + c' keys
	except KeyboardInterrupt:
		print("\n\n ...Exiting program\n\n")
		sys.exit(0)