Hey guys. Wassup?? Well, I was trying to write this code for like two days now and I am just extremely stuck. Like can someone please help me?? I am so confused.
So for this code, I have to get input and insert it into the equation a = bx. That part is simple. Then if the answer is an integer, I have to print the integer, and I need to print either no solutions or many solutions. So far, I've written this as my answer:
a = int(input())
b = int(input())
x = b/a
if a == b:
elif x % 1 == 0:
y = eval('x')
For starters, the system wants my answer in the form of -2. But the code keeps outputting -2.0. How do I make it stop doing that? And can you guys look at the 'no solution' and 'many solutions' part of the answer? I'm pretty sure that's off. Also can someone tell me if I'm using the eval statement right? I just got introduced to that pretty recently and am not sure if it's correct. Thank you!!
Instead of using
eval() (Don't it is bad practice) you could just do
y = int(x). When you divide a number by another, the answer is always a float (With decimal point), which you then can convert into an integer with the