![]() |
|
[Python] Currency Converter - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Currency Converter (/showthread.php?tid=3857188) |
Currency Converter - XBatt - Nov 10, 2013 Here is a currency converter I made, I know it's not very efficient and there are other ways to make this better. Please provide suggestions, also what does the "def" do in python? PHP Code Thanks * - glob - Nov 10, 2013 Wow. Yes that code could be improved, a lot. def means declare function. Simply put, it basically creates a variable that, when called, will execute instructions. PHP Code The body of the function is not executed until the function is called. You can read more about functions here: http://docs.python.org/release/1.5.1p1/tut/functions.html and here: http://www.tutorialspoint.com/python/python_functions.htm * - XBatt - Nov 10, 2013 Ah, that's quite easy to understand. And how can I improve the code? Also, when writing out the body of the def how do you tell python this is the end of the body of def? * - glob - Nov 10, 2013 (Nov 10, 2013 11:30 AM)XBatt Wrote: Ah, that's quite easy to understand. And how can I improve the code? The body of the function is indented. Once indentation ceases, the interpreter assumes that that is the end of the function declaration. * - XBatt - Nov 10, 2013 (Nov 10, 2013 12:26 PM)Cᴀᴛᴀʟʏsᴛ Wrote: The body of the function is indented. Once indentation ceases, the interpreter assumes that that is the end of the function declaration. Ah okay, and how can I make my currency converter more efficient? or simpler for the user? Can anyone help me with this? Advice? Tips? |