We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Introduction
- Python: Division
- Discussions
Python: Division
Python: Division
Sort by
recency
|
999 Discussions
|
Please Login in order to post a comment
Quick tip: Use
/
for float division (5 / 2
=2.5
) and//
for integer division (5 // 2
=2
).If you're working with division in Python, make sure to use / for float division and // for integer division. For example, 5 / 2 returns 2.5 while 5 // 2 returns 2. You can find more practical examples and guides like this on websites such as VisaCheckQatar.
I can solve both 0 and 1 Test case separately. When i write both cases in one place then both cases are wrong, help me out guys, please!
It seems like the issue is handling test cases 0 and 1 together. Try separating the logic for each test case like this:
For test case 0, handle it with an if condition to avoid errors (like division by zero). For test case 1, manage it separately with an elif. That way, you prevent both test cases from interfering with each other.
Hope that clears it up! Let me know if you need more help.
a=int(input()) b=int(input()) print(a//b,"\n",a/b)
If you're working with division in Python, make sure to use / for float division and // for integer division. For example, 5 / 2 returns 2.5 while 5 // 2 returns 2.
If you're exploring more coding tips, check out this helpful resource on Menu — it covers a variety of tech and programming topics!