gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
Write a python code to sum to input numeric values
- User
Write a python code to sum to input numeric values
- Assistant
Here is a sample Python code to sum two input numeric values:
num1 = input("Enter first number: ") num2 = input("Enter second number: ") sum = float(num1) + float(num2) print("The sum of {0} and {1} is {2}".format(num1, num2, sum))The above code takes two input values from the user, converts them to floating-point numbers, adds them together, and prints the sum. The output will look like this:
Enter first number: 2.5 Enter second number: 3.5 The sum of 2.5 and 3.5 is 6.0Note: If you need to handle integer values only, you can replace
float(num1)andfloat(num2)withint(num1)andint(num2)respectively.