Python Forum
def functions creation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
def functions creation
#5
(Jun-19-2020, 03:09 PM)ndc85430 Wrote: A few things:

1. Your indentation on lines 3-10 is incorrect.
2. When will the condition on line 3 ever be True?
3. Lines 4, 5 and 6: you compute some values and throw the results away. Why? Also, those expressions don't really make any sense: at the very least, you're using =, which is for assignment and aren't using any variables so assignment doesn't make sense. Did you mean to compare equality? Even in that case, I'm not really sure what the expressions as a whole are meant to do, given there's also a <= in them.
4. You pass a parameter to the function, but never use it anywhere in the function.
5. Your elifs don't have conditions. Remember that elif means "else if", so needs to have a condition to make sense.
6. Are you using pytest as your test framework? In any case, you shouldn't need the print on line 28; the test framework will report which tests have passed and failed. Technically, you only have one test, but the framework will show you when either of the assertions fail anyway.

hey, very new to python, i sort put it together and trying to guess my through it, i kept getting syntax errors on every line, with line 28: its what the uni have programmed so i wont touch that XD.

most of it is a guess, the course dont really explain things all that well. i will need to keep guessing it, if this post is to much or not aloud please remove XD but if not any tips or hints would be amazing.

Sam
Reply


Messages In This Thread
def functions creation - by samh625 - Jun-19-2020, 10:59 AM
RE: def functions creation - by pyzyx3qwerty - Jun-19-2020, 02:32 PM
RE: def functions creation - by ndc85430 - Jun-19-2020, 03:09 PM
RE: def functions creation - by samh625 - Jun-19-2020, 10:09 PM
RE: def functions creation - by samh625 - Jun-19-2020, 03:10 PM
RE: def functions creation - by ndc85430 - Jun-20-2020, 03:10 AM
RE: def functions creation - by samh625 - Jun-20-2020, 03:28 PM
RE: def functions creation - by Yoriz - Jun-20-2020, 03:40 PM
RE: def functions creation - by ndc85430 - Jun-21-2020, 08:29 AM
RE: def functions creation - by samh625 - Jun-21-2020, 08:35 AM
RE: def functions creation - by ndc85430 - Jun-21-2020, 08:43 AM
RE: def functions creation - by samh625 - Jun-26-2020, 09:56 AM
RE: def functions creation - by pyzyx3qwerty - Jun-26-2020, 02:46 PM
RE: def functions creation - by DeaD_EyE - Jun-26-2020, 04:24 PM
RE: def functions creation - by samh625 - Jun-26-2020, 10:29 PM
RE: def functions creation - by TGH - Jun-30-2020, 08:28 PM
RE: def functions creation - by niusia - Jul-17-2020, 04:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020