Python Practice Problem

how can i remove that space i have marked in the output?
end and sep arent working

Hey @devchopra999_11c6416ab7f09bbf,
Use f strings method for printing or .format method, then it will work fine.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Python doubt 13

the format method worked and its giving the desired output now, but i am still getting an error in test case 0 , i tried different inputs but it gives the correct output

https://online.codingblocks.com/app/player/209779/content/201856/4715/code-challenge

hey @devchopra999_11c6416ab7f09bbf ,

i don’t know why i am not able to access the link you provided. Will ask the team to help me in this.

till then , can you please upload your code on ide.codingblocks.com , and also along with this , copy paste the question of this challenge there, it would be much easier to help then.

sure
Given a non negative integer A, print all the pairs of integers(a,b) such that

a and b are positive integers

a<=b and

a^2 + b^2 = A

0 <= A

Input Format

First line contains T , number of test cases. Next T lines contain a single integer A each.

Constraints

A<=1000

Output Format

T lines each containing a pair (a,b) in sorted order.

Sample Input

3
1
9
25

Sample Output

(0,1)
(0,3)
(0,5) (3,4)
T=int(input())

def roots(value):

    if value<=1000 and value>=0:

        q=int((value+1)**0.5)

        for i in range(q+1):

            for j in range(q+1):

                if i*i + j*j==value and i<=j:

                    print("({},{})".format(i,j),end=" ")

        print()

for i in range(T):

    element=int(input())

    if element<=1000 and element>=0:

        roots(element)

i am unable to get the share link from ide
edit: i figured it out

hey @devchopra999_11c6416ab7f09bbf ,
Yeah your code is working correctly.

Can you tell me what error are your getting on failed test cases.
like TLE or something ?

it says “Wrong Answer”

is it a space between them ?

1 Like

yes it is according to the question

hey @devchopra999_11c6416ab7f09bbf ,
just give one try with removing the conditions of < 1000 and > 0 ones

it worked both the test cases were right this time but i didnt understand what happened since those constraints were supposed to be implemented for the program to be right, is it bcz there’s some fault in the test case?

yeah thats a fault in test cases not from your side

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.