Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'classes.': 0.07; 'definitions': 0.07; 'function,': 0.07; 'parameter': 0.07; 'python': 0.09; 'imports': 0.09; 'suggestions:': 0.09; 'thread,': 0.09; 'toss': 0.09; 'undefined.': 0.09; 'def': 0.10; 'subject:python': 0.11; 'bind': 0.16; 'expects': 0.16; 'field).': 0.16; 'purposes.': 0.16; 'spec,': 0.16; 'subject:programming': 0.16; 'string': 0.17; 'wrote:': 0.17; 'certainly': 0.17; 'else,': 0.17; 'message-----': 0.17; 'working.': 0.17; 'input': 0.18; 'math': 0.20; 'import': 0.21; 'do.': 0.21; 'wednesday,': 0.22; 'programming': 0.23; 'user.': 0.23; 'tried': 0.25; 'header:In- Reply-To:1': 0.25; 'expand': 0.26; 'fixed': 0.28; 'lines': 0.28; 'received:209.85.212': 0.28; 'crash': 0.29; 'large.': 0.29; 'pile': 0.29; 'definition': 0.29; 'classes': 0.30; 'function': 0.30; '(and': 0.32; 'asking': 0.32; 'skip:- 10': 0.32; 'print': 0.32; 'int': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'posting': 0.35; 'received:209.85': 0.35; 'subject:': 0.36; 'explain': 0.36; 'but': 0.36; 'email addr:python.org': 0.36; 'problems': 0.36; 'two': 0.37; 'sent:': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'sure': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'help': 0.40; 'your': 0.60; 'from:no real name:2**0': 0.60; "you've": 0.61; 'first': 0.61; 'email name:python-list': 0.62; 'close': 0.63; 'different': 0.63; 'email addr:gmail.com': 0.63; 'frequently': 0.65; 'reply': 0.66; 'user,': 0.69; 'wish': 0.70; 'discovered': 0.83; '2013': 0.84; 'confusing': 0.84; 'fortunately,': 0.84; 'matters.': 0.84; 'str.': 0.91; 'angel': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:from:to:references:in-reply-to:subject:date :mime-version:content-type:content-transfer-encoding:x-priority :x-msmail-priority:importance:x-mailer:x-mimeole; bh=1j0oFQ6M9eMd41hyrVXUyQzHz6Aq9RTa3Y4kgwC2JaY=; b=l9sSlNbh91lpiqFFfZipp/pw/Cx1G/vEADZlBdAaxTIE26gJ+7XV3wPXbfc2UNrrP9 Hh/CX1iT0esfAeRo+eFs8vgTb4ZeDdK2d9hwSUn8SYWG8Nkj59d6vhMcpCmecR70cZJW 58LKQXM+Qjdd1J3XRmWeaAriFGvs+2evqum+88Vr9EgQSQI5G6hSxtP7tIFrkXYSGA3S SHMla71aZRlCWH3xBp239flHcEZfb5hmrE4danfgIHK7HDW/B62eugaIKg++5LcP/wgx 1eEpKKVGKMtAgJtR3UKzfJr8vUoJM8MFKOzIc5lGeNqC13rVh0Iok8ktrdsuXbK8ztIq J4Vg== X-Received: by 10.180.79.194 with SMTP id l2mr5457641wix.22.1357764333924; Wed, 09 Jan 2013 12:45:33 -0800 (PST) From: kwakukwatiah@gmail.com To: References: <50EDB056.9060500@davea.name> In-Reply-To: <50EDB056.9060500@davea.name> Subject: Re: new to python and programming at large. Date: Wed, 9 Jan 2013 20:45:03 -0600 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 15.4.3508.1109 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 87 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357764335 news.xs4all.nl 6946 [2001:888:2000:d::a6]:36947 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36518 -----Original Message----- From: Dave Angel Sent: Wednesday, January 09, 2013 12:00 PM To: python-list@python.org Subject: Re: new to python and programming at large. On 01/09/2013 05:28 PM, kwakukwatiah@gmail.com wrote: > thanks for ur help I wz able to do it.but I wish to expand it by asking a > user to input a number for the sqrt to be calculated it I dd it this way > but its not working. > > > from math import sqrt > number = raw_input('enter a number:') > def number(y): > return number(Y) > > > > Please don't keep posting new messages on the same topic. When adding to a thread, use Reply (and make sure python-list is in the to: or cc: field). This program has a pile of problems with it. You've used the name 'number' for three different purposes. Let me explain what those lines do. number = raw_input(... Capture a string from the user. Type is str. def number(y): toss out the string the user entered, and bind that name instead to a function definition that takes a parameter y. return number(Y) Attempt to call your own function recursively, but first crash since Y is undefined. Y is not the same as y. Fortunately, you never actually call the function, by any name. You never used the string you got from the user, but if you had fixed everything else, you'd have discovered that sqrt() expects either an int or a float. Suggestions: put your imports first then put your function definitions and classes only then put your initialization and calls to those functions and classes. Make sure you don't use the same name for two different purposes. It can frequently be okay, but it's certainly confusing for a beginner. Watch the case of any names you use. It matters. You don't have a spec, but perhaps this is close to what you want (untested): from math import sqrt def squareroot(y): return sqrt(y) number = float(raw_input('enter a number:')) print squareroot(number) -- DaveA thanks so much it worked.I have tried and tried.look at what I was doing. me = raw_input("Enter a value:") from math import sqrt def squareroot(y): me = squareroot(y) return squareroot(y) thanks I am very greatful.