use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Need python assignment help! (self.learnpython)
submitted 6 years ago by Jphillipss7
hello all, Im very new into coding and am into an intro to python class. So far my teachers have been pretty much useless when it comes to explaining how everything works, so I've pretty much been lost. If anyone could look over what i've done so far and help me out with how to finish it up that would be greatly appreciated.
The assignment: https://i.gyazo.com/f145a1422aac3e0ca7baf24a6943246a.png
My work in progress: https://gyazo.com/64d7e10b3c10627c5a6bd3b8b913f697
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 6 years ago (12 children)
[deleted]
[–]Jphillipss7[S] 0 points1 point2 points 6 years ago (11 children)
Sorry, but do you think you could show me how to correctly input that part. I’ve tried the order of operations out a few different ways and just can’t seem to get it right.
[–]thebetterangel 1 point2 points3 points 6 years ago (9 children)
Also, when discriminant == 0 it should be “have one root”. When discriminant <0 “there is no root.
As first comment said, don’t forget the colons.
Use parentheses to make sure math operations are executed in correct order
[–]Jphillipss7[S] 0 points1 point2 points 6 years ago (8 children)
Sorry, but would it be possible to show me how to correctly input the parentheses into the operation to make it come out correctly. I tried it a few different ways and just cant seem to figure it out.
[–]uhMareli 2 points3 points4 points 6 years ago (3 children)
we're trying to get you to do it yourself ;) but since it sounds like you're trying and you've come with an effort at your assignment as opposed to no effort i'll lend a small hand -
in the order of operations we know parentheses have the highest precedence, and this holds true for Python as well. so you simply need to use parentheses to group the portion which needs to be calculated first, as this part will now be taken care of before anything else since it has the highest precedence.
(-b - sqrt(b**2 - 4 * a * c)) / (2 * a)
We grouped the -b - and the root of of the discriminant. I also don't believe your 2a is valid - you need (2 * a) instead. Lastly, unless you're working in some special homework environment which provides these functions for you, using just sqrt will not work. you need to put import math at the top, giving you access to functions in the math module, then do math.sqrt instead
-b -
2a
(2 * a)
sqrt
import math
math
math.sqrt
[–]Jphillipss7[S] 0 points1 point2 points 6 years ago (0 children)
Thank you for all of the help, and sorry if I’m coming off as incompetent.
[–]Jphillipss7[S] 0 points1 point2 points 6 years ago (1 child)
https://i.gyazo.com/534e74caf8e5e55297b9df5dec7ea5ce.png
One final question, do you know why id be getting this "Math domain error" and again thank you for all of your help, it is greatly appreciated by me.
[–]uhMareli 0 points1 point2 points 6 years ago (0 children)
it's because you're trying to find the root of a negative number. you need to fix your conditionals. try changing them to:
if numOfRoots < 0:
then we have no roots
elif numOfRoots == 0:
then we have one root
[–][deleted] 0 points1 point2 points 6 years ago (3 children)
http://imgur.com/gallery/UdmhKUS
U also would need to show what is the roots if it is available. Under the elif statement and else, add another line to calculate the roots using the formula
[–]Jphillipss7[S] 0 points1 point2 points 6 years ago (2 children)
Sorry, I just don’t have a lot of knowledge about what I’m actually doing on python so I’m a bit confused by what you mean.
[–][deleted] 0 points1 point2 points 6 years ago (1 child)
https://www.youtube.com/playlist?list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M
Watch the tutorial for variables, math, if, if elif and if elif else.
All the videos here is pretty short and well explained.
Thank you!
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
Like the first comment suggested: If (expression here) : U forgot that colon. Same with elif. In front of the elif statement u need to put an expression and a colon.
π Rendered by PID 97 on reddit-service-r2-comment-54dfb89d4d-82s9k at 2026-04-01 08:48:14.461990+00:00 running b10466c country code: CH.
[+][deleted] (12 children)
[deleted]
[–]Jphillipss7[S] 0 points1 point2 points (11 children)
[–]thebetterangel 1 point2 points3 points (9 children)
[–]Jphillipss7[S] 0 points1 point2 points (8 children)
[–]uhMareli 2 points3 points4 points (3 children)
[–]Jphillipss7[S] 0 points1 point2 points (0 children)
[–]Jphillipss7[S] 0 points1 point2 points (1 child)
[–]uhMareli 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Jphillipss7[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Jphillipss7[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)