+ 2

How to do it???

The input is the expression x+y, where x and y are digits, i.e. integers from 0 to 9 inclusive. You need to calculate it and output the result. The first line contains a single integer t (1≤t≤100) — the number of input data sets. For example: Input: "5+3 6+8 7+3" Conclusion: "8 14 10"

21st Feb 2023, 1:47 PM
python
3 Antworten
+ 4
What is your question? edit: Split the input at the blank space to separate the expressions. Then you can split the individual expression at "+" to get get x and y. Once you have x and y, convert them to a numeric data type and add them
21st Feb 2023, 1:57 PM
Lisa
Lisa - avatar
+ 3
That would be the lazy version that the teacher probably did not intend ;)
21st Feb 2023, 3:39 PM
Lisa
Lisa - avatar
+ 2
Lisa maybe directly passing the splitted value in eval will be a better choice
21st Feb 2023, 3:20 PM
Just Some Random Guy
Just Some Random Guy - avatar