Mathematics (Code Coach) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

Mathematics (Code Coach)

Wrote code "Mathematics", error in tests 4 and 5. Who knows what is in these tests?

24th Sep 2020, 9:39 AM
Konstantin K
Konstantin K - avatar
15 Answers
+ 3
Konstantin K I think I got this problem. Please try at the end of your code write: if k == 1: print("none") but the last line with tab distance from left. Happy coding!
29th Sep 2020, 3:14 PM
JaScript
JaScript - avatar
+ 7
Rik Wittkopp Yes and free access for 30 days after completing BTS
24th Sep 2020, 10:14 AM
Konstantin K
Konstantin K - avatar
+ 7
McInventor29 I use the function ival() too.
29th Sep 2020, 1:35 PM
Konstantin K
Konstantin K - avatar
+ 6
The tests are hidden to force you to think about scenarios that are within the brief, but may not be immediately obvious. This approach helps develop logic thinking. PS: Is 'Mathematics' only available to pro?
24th Sep 2020, 9:46 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 6
JaScript Yes of course.
24th Sep 2020, 12:02 PM
Konstantin K
Konstantin K - avatar
+ 6
JaScript I understood what the problem is, I fix the code
24th Sep 2020, 3:35 PM
Konstantin K
Konstantin K - avatar
+ 6
I fixed the code, but still there was an error in test 4.
24th Sep 2020, 8:51 PM
Konstantin K
Konstantin K - avatar
+ 6
JaScript I need to know that in test 4.
25th Sep 2020, 7:10 AM
Konstantin K
Konstantin K - avatar
+ 6
Changed the code, everything works. What was the problem I did not understand. https://code.sololearn.com/cts0oL4WuJrF/?ref=app
25th Sep 2020, 8:19 PM
Konstantin K
Konstantin K - avatar
+ 2
I was stuck on this one too, but I found a really simple way to solve it. (Hint: use the function eval(). ) Also, I’m using SoloLearn Pro because of the BTS challenge.
29th Sep 2020, 1:25 PM
McInventor29
McInventor29 - avatar
+ 1
Did you test your code on the Playground and know how it works?
24th Sep 2020, 10:55 AM
JaScript
JaScript - avatar
+ 1
Konstantin K And as I understand what was asked, your code does it. Where is your attempt?
24th Sep 2020, 3:28 PM
JaScript
JaScript - avatar
+ 1
What can be done without your attempt, what do you expect?
25th Sep 2020, 7:06 AM
JaScript
JaScript - avatar
+ 1
answ = int(input()) math_expr = input().split() for i in math_expr : if eval(i)==answ: print("index " + str(math_expr.index(i))) break else : print('none')
6th Dec 2021, 8:53 AM
Mas'ud Saleh
Mas'ud Saleh - avatar
+ 1
result = int(input()) expr = input().split(' ') bool = [eval(expr[i]) == int(result) for i in range(len(expr))] print("index "+str(bool.index(True)) if True in bool else "none")
14th Dec 2021, 8:34 AM
Mateo González Bufi
Mateo González Bufi - avatar