AI Chatbot Python

👤 Sharing: AI
```python
def main():
    """
    This is a placeholder function.  Replace with your actual program logic.
    """
    print("Hello from Python!")
    # Example:  Calculate the factorial of a number
    try:
        num = int(input("Enter a non-negative integer: "))
        if num < 0:
            print("Factorial is not defined for negative numbers.")
        else:
            factorial = 1
            for i in range(1, num + 1):
                factorial *= i
            print(f"The factorial of {num} is {factorial}")
    except ValueError:
        print("Invalid input. Please enter an integer.")

if __name__ == "__main__":
    main()
```
👁️ Viewed: 110

Comments