![]() |
|
[Python] Unsure about Python Expression Syntax - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Unsure about Python Expression Syntax (/showthread.php?tid=6179016) |
Unsure about Python Expression Syntax - Poojar102 - Oct 29, 2021 I've been asked the following question and I'm unsure as I was able to enter all of them (in IDLE) then use the print() function to return the given values successfully with no errors. Thanks in advance. RE: Unsure about Python Expression Syntax - tux1 - Oct 30, 2021 (Oct 29, 2021 10:20 PM)Poojar102 Wrote: I've been asked the following question and I'm unsure as I was able to enter all of them (in IDLE) then use the print() function to return the given values successfully with no errors. I think the answer they are looking for is d, the reason is because it has the semicolon at the end. Although there is no reason why this won't run it is generally discouraged in python to use a semicolon at the end of a line as opposed to compiled languages. https://www.askpython.com/python/examples/semicolon-in-python https://stackoverflow.com/questions/8236380/why-is-semicolon-allowed-in-this-python-snippet https://towardsdatascience.com/stop-using-semicolons-in-python-fd3ce4ff1086 RE: Unsure about Python Expression Syntax - Poojar102 - Oct 30, 2021 (Oct 30, 2021 04:33 AM)tux1 Wrote: I think the answer they are looking for is d, the reason is because it has the semicolon at the end. Although there is no reason why this won't run it is generally discouraged in python to use a semicolon at the end of a line as opposed to compiled languages. Yeah that's why I'm confused because all of the options are viable. Thanks for the detailed response though man, appreciate it! (Oct 30, 2021 04:33 AM)tux1 Wrote: I think the answer they are looking for is d, the reason is because it has the semicolon at the end. Although there is no reason why this won't run it is generally discouraged in python to use a semicolon at the end of a line as opposed to compiled languages. Congratulations on your 11,000ᵗʰ post btw RE: Unsure about Python Expression Syntax - Sajuuk - Oct 31, 2021 I don't understand it, either. Python is not C. tux has linked to the explanations of why Python doesn't need semicolons. When I need to show the end of some process/function in Python for whatever reason, I just comment "# END OF FUNCTION". :/ RE: Unsure about Python Expression Syntax - Maquina - Nov 1, 2021 Python ignores the semicolon for some reason. There was once when I was doing a lot of Java and moved down to Python, still had the habit of putting semicolons, and found out it doesn't stop the code from running, lol. But it's definitely D, without a doubt, as the other ones are perfectly fine syntax-speaking. |