there is none here its complete blank but not sure what to do next can you please help me i have already shared the code and the codition he is asking me to follow
You did not delete all of the code. Delete every line, the whole function.
If the square_target
is equal to 1
, declare a variable root
and assign it the value 1
. Also, print the message 'The square root of {square_target} is 1'
. Remember to format the message using an f-string.
this is the condition he is saying how can i put this in the code please let me know.
Please read my previous messages
i did but it doesn’t make much sense as why should i delete everything when it doesnt say so
Please post your full current code (not a picture)
def square_root_bisection(square_target, tolerance=1e-7, max_iterations=100):
if square_target < 0:
raise ValueError('Square root of negative number is not defined in real numbers')
if square_target == 1:
root == 1
print(f'The square root of {square_target} is 1')
here is the code let me know where i am causing error
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
So you did not delete everything like you were asked?
why should i delete when it says to just add a variable to it and pass the print function?
Getting the answer so you pass the Step is honestly pointless. Understanding the Step is the only valuable thing
ok but in the above step it didnt mentioned to clear everything and write only variable to in the code that is my question
Pkdvalis is trying to help you understand the issue. You should try what they say
ok i dont mind giving it a shot but just to be clear it should have been mention in the lines when they describe the situation so that we can easily grab the context.
You are a detective trying to find the problem. You need to take out your magnifying glass and inspect each line
root == 1
print(root)
This is the magnifying glass. Look at your first line and see if it’s working
You can’t tell if it’s working in the function def because you are simply defining a function and no code is running.
If you don’t want to delete the code you could put it at the top
def square_root_bisection(square_target, tolerance=1e-7, max_iterations=100):
if square_target < 0:
raise ValueError('Square root of negative number is not defined in real numbers')
if square_target == 1:
root == 1
print(root)
still the same issue i am not sure how can i go from here if i delete everything as you requested then obviously the code wont pass through as i dont have all steps so please just tell me how can i add root == 1 variable into this scenario?
You need to delete all this.
Or put this at the top:
root == 1
print(root)
Again, we are not trying to fix your code for you and give you the answer. We’re trying to show you how to investigate problems in your code for yourself
You already know how. When you finally run the test I’ve asked you will understand.
Please read the instructions on posting formatted code.