473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Defining functions

I'm a newby to python, and have been learning it for a little while, but I
have a problem. I can't grasp the concept of functions..... If someone could
explain that in lamers tearms that would be appreciated. One more question, can
python be applied to manipulate things in Windows? Like maybe restart my
computer through python, or record keystrokes???
Thanks alot guys, Pat
Jul 18 '05 #1
2 1798
On 20 Nov 2003 05:21:09 GMT, Jimith87 wrote:
I'm a newby to python, and have been learning it for a little while
Welcome! Some time soon you should work through the Python tutorial:

<http://www.python.org/doc/current/tut/>
I can't grasp the concept of functions..... If someone could explain
that in lamers tearms that would be appreciated.


A function is an object that contains code to be executed. It allows
you to parcel up a conceptual lump of code that does one distinct thing
(say, read a number from an input stream, or calculate a value from two
inputs) and then invoke that bundle of code at other places in your
code.

A function can return a value, so you can assign that value to another
object or use it as input to another function. A function can be
parameterised; that is, you can pass the function one or more input
parameters that will affect its behaviour.

Functions allow you to avoid repeating code that is largely similar
throughout your code; it also allows you to abstract a block of code to
a single conceptual operation, making the code that uses it easier to
read.
It sounds like you would benefit from the tutorial "How To Think ike A
Computer Scientist: Learning With Python". It's here:

<http://www.ibiblio.org/obp/thinkCSpy/>

--
\ "Computers are useless. They can only give you answers." -- |
`\ Pablo Picasso |
_o__) |
Ben Finney <http://bignose.squidly.org/>
Jul 18 '05 #2
Jimith87 wrote:

I'm a newby to python, and have been learning it for a little while, but I
have a problem. I can't grasp the concept of functions..... If someone could
explain that in lamers tearms that would be appreciated. One more question, can
python be applied to manipulate things in Windows? Like maybe restart my
computer through python, or record keystrokes???


Planning to write some viruses? ;-)

-Peter
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sriram Chadalavada | last post by:
Hello everyone, I am a newbie to Python with experience in C programming. For my project, I am re-writing C routines as Python functions. I am currently using raw numerical values and was...
7
by: Harry Pehkonen | last post by:
I have been defining new class methods when I'm trying to simplify some code. But I'm thinking I should just define functions within that method because they aren't useful from the outside anyway....
8
by: Martin Magnusson | last post by:
I want to create a few objects which all share a lot of common features, so they should all derive from the same base class. However, each of them needs individual definitions of two functions. So...
7
by: Senthilraja | last post by:
I have the following program using templates. Someone please let me know the syntax to be used for defining the member functions push, pop etc. as non-inline functions. #include <iostream>...
12
by: Matt Garman | last post by:
I'd like to create a "custom output facility". In other words, I want an object whose use is similar to std::cout/std::cerr, but offers more flexibility. Instead of simply writing the parameter...
4
by: Bilgehan.Balban | last post by:
Hi, Generally in my C code, I use the following convention to return success or failure: a) For functions that return a pointer, (allocation, filling-in a structure etc.) return Null for all...
38
by: Steven Bethard | last post by:
> >>> aList = > >>> it = iter(aList) > >>> zip(it, it) > > That behavior is currently an accident. >http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1121416
0
by: Nataraj Narayana via DotNetMonster.com | last post by:
I have reqirements of defining prototypes for C++ dll function in C# so that I can use p/invoke method to access the dll's functions. Can anyone please suggest how to write prototypes in C# for...
2
by: Helpful person | last post by:
I wish to access several pictures on my page by defining them as an array. This way I can either loop through them or access them by array index. I am a beginner at Javascript so please keep...
11
by: Tempo | last post by:
Hello. I am getting the error that is displayed below, and I know exactly why it occurs. I posted some of my program's code below, and if you look at it you will see that the error terminates the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.