Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defining function error
#1
I am working through the following question as apart of an assignment:

You have been informed that 1 mile is equivalent to 1.61 kilometres.

Based on the given facts create a function called km with a single parameter called miles, (which you can assume will always be a valid number) and returns the equivalent number of kilometres.

Hint: Use 1.61 value while making the conversion: km = miles * 1.61


I have used the following code for this:

def km(miles):
    kilometers = miles * 1.61
    
    return kilometers
When I submit this for feedback it says that the code is wrong:

Error:
Your result was in the wrong type ---------- - You returned type: float - Expected type: function
I am new to coding in general so any help on this would be really appreciated.
buran write Mar-27-2025, 11:41 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
This is not python error. This is result/output from the auto-grading system they use to verify the answer you submit. Check the requirements how you should submit your answer.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Defining a function Hudjefa 6 1,914 Aug-24-2024, 02:36 PM
Last Post: snippsat
  Conjugate Gradient having issues with defining A (function to solve [A]{x} = {b} ) DimosG 2 4,147 Sep-21-2021, 08:32 PM
Last Post: 1968Edwards
  Defining a function with input abcd 5 5,149 Feb-21-2021, 02:34 AM
Last Post: NullAdmin
  When Defining a Function with an Equation as a Default Argument, which Value Is Used? OJGeorge4 4 4,554 Apr-09-2020, 08:48 AM
Last Post: DeaD_EyE
  IDLE indenting 29 columns after defining function Cosmo_Kane 1 3,322 Jun-03-2018, 08:53 AM
Last Post: Larz60+
  Defining a Function mattt1998 4 5,153 Dec-14-2017, 07:02 AM
Last Post: buran
  Defining an fsolve function to call later hegdep 1 4,752 Oct-25-2017, 07:38 AM
Last Post: hegdep
  Error in using the output of one function in another function (beginner) MadsPJ 6 7,293 Mar-13-2017, 03:06 PM
Last Post: MadsPJ
  init vs_init_ while defining method/function? hsunteik 1 4,913 Dec-24-2016, 08:27 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

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