gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Hello! How can i help you today?
- User
Assistant: Hello! How can i help you today? User: Give me python sum of addition program Assistant:
- Assistant
Sure! Below is a simple Python program that takes two numbers as input from the user and then calculates and prints their sum:
# Function to add two numbers def add_two_numbers(num1, num2): return num1 + num2 # Take input from the user try: number1 = float(input("Enter the first number: ")) number2 = float(input("Enter the second number: ")) # Call the function and print the result result = add_two_numbers(number1, number2) print(f"The sum of {number1} and {number2} is: {result}") except ValueError: print("Please enter valid numbers.")You can run this program in your Python environment. It will prompt you to enter two numbers and then display their sum. If the input is not a valid number, it will show an error message.