Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

hi guys, i really need ur help in python with my homework, please :<

+1 vote
asked Apr 5, 2020 by DariaSNT (130 points)
Write a program that calculates the sum of three numbers entered as a character string. All numbers are integers.
Enter the expression:
Answer: 60

5 Answers

–1 vote
answered Apr 6, 2020 by Vaishnavi (180 points)
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
num3 = input('Enter third number :')
# Add three numbers
sum = float(num1) + float(num2) +float(num3)

# Display the sum
print('The sum of {0},{1} {2} is {3}'.format(num1, num2, num3, sum))
+1 vote
answered Apr 6, 2020 by Omkar Joshi (180 points)

print("Sum of a ,b and c is",int(a)+int(b)+int(c))
0 votes
answered Apr 8, 2020 by Jag Man Gurung (220 points)
Hello there. You can use eval() function for your question.

expression = "12+3+45"

Output: 60.
commented Apr 9, 2020 by DariaSNT (130 points)
thanks a lot!
0 votes
answered Apr 17, 2020 by Khadeja Y (160 points)

num = input("Enter the expression : \n")



Enter the expression : 
Answer: 60

0 votes
answered Apr 24, 2020 by Anto (140 points)
I know the "eval" function is made for this, but I'm guessing you're supposed to find the solution yourself, not already made.

What about (Python3.x) :

line = input().split('+')
    numbers = [int(n) for n in line]
except ValueError:
    print("Invalid line format.")
    result = sum(numbers)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.