Untitled

mail@pastecode.io avatar
unknown
python
a month ago
1.6 kB
2
Indexable
Never
def user_input():
    multiplicand = int(input("\nEnter the multiplicand: "))
    multiplier = int(input("Enter the multiplier range: "))
    times = int(input("Enter how many times to display the multiplication table: "))
    return multiplicand, multiplier, times

# Function to confirm user input
def confirm_user_input(multiplicand, multiplier, times):
    while True:
        print("\nConfirming your inputs:")
        print(f"Multiplicand: {multiplicand}")
        print(f"Multiplier range: 1 to {multiplier}")
        print(f"Times to display: {times}")
        correct = input("\nIs this information correct? (yes/no) ").strip().lower()
        if correct == 'yes':
            return True
        elif correct == 'no':
            return False
            user_input()
        else:
            print("Invalid input. Please enter 'yes' or 'no'")



# Function to process input and display output
def process_and_display(multiplicand, multiplier, times):
    print("\nMultiplication Table:")
    for i in range(1, times + 1):
        product = multiplicand * i
        print(f"{multiplicand} * {i} = {product}")


# Main function to run the script
def main():
    name = input("Hello, welcome to my multiplication generator, what is your name? ")
    multiplicand, multiplier, times = user_input()
    confirm_user_input(multiplicand, multiplier, times)
    process_and_display(multiplicand, multiplier, times)
    print (f"\nThank you {name} for using my multiplication generator!")

# Entry point of the script
if __name__ == "__main__":
    main()
Leave a Comment