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.
Thanks in advance.
|
Python
Unsure about Python Expression Syntax |
(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/example...-in-python https://stackoverflow.com/questions/8236...on-snippet https://towardsdatascience.com/stop-usin...3ce4ff1086
Oct 30, 2021 07:27 AM
(This post was last modified: Oct 30, 2021 07:36 AM by Poojar102.)
(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
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.
|
|
|
| Possibly Related Threads... | |||
| Thread / Author | Replies | Views | Last Post |
| [Python] by Bass_ReevesAug 20, 2023 01:44 AM | 9 | 632 |
Aug 20, 2023 01:44 AM Last Post: Lucky4L |
| [C] by aeiroDec 21, 2019 05:47 PM | 9 | 314 |
Dec 21, 2019 05:47 PM Last Post: Emp3hack |
| [Python] by Wic12Sep 23, 2019 09:27 PM | 1 | 163 |
Sep 23, 2019 09:27 PM Last Post: datguy.dev |