Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97086
| Path | csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'exercise': 0.03; 'converts': 0.07; 'main()': 0.07; "'''": 0.09; 'assigning': 0.09; 'subject:Modules': 0.09; 'def': 0.13; '"def"': 0.16; "'))": 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'main():': 0.16; 'margin': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'parameter,': 0.16; 'received:192.168.1.4': 0.16; 'run.': 0.16; 'subject:Learning': 0.16; 'wrote:': 0.16; 'all,': 0.20; 'work,': 0.21; 'arguments': 0.22; 'parameter': 0.22; 'pass': 0.22; 'programming': 0.22; 'ignored.': 0.23; 'passing': 0.23; 'slightly': 0.23; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'parameters': 0.27; 'defining': 0.27; "skip:' 10": 0.28; 'looks': 0.29; 'asks': 0.29; 'indentation': 0.29; 'convert': 0.29; 'code': 0.30; 'anyone': 0.32; 'problem': 0.33; 'but': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'seem': 0.37; 'doing': 0.38; 'anything': 0.38; 'why': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'email addr:gmail.com': 0.62; 'distance': 0.63; 'converter': 0.66; 'saving': 0.70; 'float,': 0.84; 'why?': 0.91 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=reVG18bgZXmLN9JrlJwA:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett@:2500 |
| Subject | Re: Learning Modules, Arguments, Parameters (imma noob) |
| To | python-list@python.org |
| References | <7ad8941d-04aa-42c5-82e9-10cdf02ab695@googlegroups.com> |
| From | MRAB <python@mrabarnett.plus.com> |
| Date | Thu, 24 Sep 2015 20:25:55 +0100 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
| MIME-Version | 1.0 |
| In-Reply-To | <7ad8941d-04aa-42c5-82e9-10cdf02ab695@googlegroups.com> |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.141.1443122761.28679.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443122761 news.xs4all.nl 23855 [2001:888:2000:d::a6]:59410 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97086 |
Show key headers only | View raw
On 2015-09-24 19:45, codywcox@gmail.com wrote:
> I seem to be having a problem understanding how arguments and parameters work, Most likely why my code will not run.
> Can anyone elaborate on what I am doing wrong?
>
> '''
> Cody Cox
> 9/16/2015
> Programming Exercise 1 - Kilometer Converter
> Design a modular program that asks the user to enter a distance in kilometers and then convert it to miles
> Miles = Kilometers * 0.6214
> '''
>
First of all, it looks like your indentation is slightly off because
"def main" line is that the left margin and the other 2 "def" lines and
the "main()" line aren't.
> def main():
You're not passing anything into 'get_input', neither are you saving
any result that it might be returning.
> get_input()
You're not passing anything into 'convert_kilo'.
> convert_kilo()
>
>
You're defining 'get_input' to accept 1 parameter 'kilo'. Why? You're
assigning to 'kilo' in the first line, so any value you _did_ pass in
would be ignored.
> def get_input(kilo):
> kilo = float(input('Enter Kilometers: '))
> return kilo
>
You're defining 'convert_kilo' to accept 2 parameters. You're using the
'kilo' parameter, but not the 'miles' parameter because you're
assigning to it on the first line, so any value you _did_ pass in would
be ignored.
> def convert_kilo(kilo,miles):
'kilo' is already a float, and you're multiplying it by a float, so the
'float' call is pointless.
> miles = float(kilo * 0.6214)
> print( kilo,' kilometers converts to ',miles,' miles')
>
> main()
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Learning Modules, Arguments, Parameters (imma noob) codywcox@gmail.com - 2015-09-24 11:45 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) MRAB <python@mrabarnett.plus.com> - 2015-09-24 20:25 +0100
Re: Learning Modules, Arguments, Parameters (imma noob) John Gordon <gordon@panix.com> - 2015-09-24 19:32 +0000
Re: Learning Modules, Arguments, Parameters (imma noob) Larry Hudson <orgnut@yahoo.com> - 2015-09-24 13:27 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) alister <alister.nospam.ware@ntlworld.com> - 2015-09-25 10:42 +0000
Re: Learning Modules, Arguments, Parameters (imma noob) Cody Cox <codywcox@gmail.com> - 2015-09-25 11:50 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) Laura Creighton <lac@openend.se> - 2015-09-25 22:15 +0200
Re: Learning Modules, Arguments, Parameters (imma noob) Laura Creighton <lac@openend.se> - 2015-09-25 22:25 +0200
Re: Learning Modules, Arguments, Parameters (imma noob) Cody Cox <codywcox@gmail.com> - 2015-09-25 13:52 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) Terry Reedy <tjreedy@udel.edu> - 2015-09-25 20:08 -0400
Re: Learning Modules, Arguments, Parameters (imma noob) Cody Cox <codywcox@gmail.com> - 2015-09-25 11:53 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) Cody Cox <codywcox@gmail.com> - 2015-09-25 12:03 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-25 13:20 -0600
Re: Learning Modules, Arguments, Parameters (imma noob) Denis McMahon <denismfmcmahon@gmail.com> - 2015-09-25 23:59 +0000
Re: Learning Modules, Arguments, Parameters (imma noob) wxjmfauth@gmail.com - 2015-09-26 00:02 -0700
Re: Learning Modules, Arguments, Parameters (imma noob) Larry Hudson <orgnut@yahoo.com> - 2015-09-25 22:55 -0700
csiph-web