Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Python 2.5 For Windows


  • Please log in to reply
5 replies to this topic

#1 Glunn11

Glunn11

  • Members
  • 262 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Idaho
  • Local time:05:06 PM

Posted 13 November 2006 - 11:14 PM

Hey!
I need some assistance learning Python 2.5. I want to be a computer programmer when I get out of high school, and Python seemed like a good language to start learning with. I've tried learning Java and C++ with really crappy tutorials and it went completely over my head. Thankfully, there's a lot of nonprogrammer guides for Python. This is the tutorial I am referring to - I'd be very grateful for some assistance at Modules and Functions and beyond.
http://www.freenetpages.co.uk/hp/alan.gauld/

Thanks!
-Glunn

BC AdBot (Login to Remove)

 


#2 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:07:06 PM

Posted 15 November 2006 - 03:39 PM

What specific questions are you having? There is a lot of material there and it would be easier to help you if you told us what you are confused about.

Also have you tried Visual Basic? Its a very easy program to start learning and Microsoft has free Visual Basic Express development software.

#3 Glunn11

Glunn11
  • Topic Starter

  • Members
  • 262 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Idaho
  • Local time:05:06 PM

Posted 15 November 2006 - 04:20 PM

Well I am confused about Modules/Functions and Handling Files.
And I need those two chapters to understand the rest of the stuff, so specifically I'd like instruction on those chapters. The tutorial only gives an example on how to save, load, etc. a very specific file and I need the example broken down into parts.
As for modules and functions he simply goes too fast for me to catch on.

#4 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:07:06 PM

Posted 15 November 2006 - 04:39 PM

A function is simply a routine that can be called over and over and always performs the same function. For example if we had a function called squared that simply took a number and timed it by itself, we would have a function in python that looked like this:

def square(n):
   s = ""
	s = s*s
   return s

Then in your code you can reference that function by having a statement like:

num = square(5)
print num

THe output of the above code would be 25, because you are passing the number 5 to the square function, which times it by itself and returns the value. This value is assigned to num and printed.

A module is basically a file that contains a series of predefined functions. Before you can add that module you would need to import it into your program as give that import a name so that you can reference these functions.

For example to import the sys module (and the functions it contains) you can type import sys. This will now make any functions within the sys module available to your program. To use a function in the sys module you must reference it by its name like this sys.dir() because the dir function is part of the sys module.

To make your own module, simply create a text file and save the functions you created into this text file and save it as a .py file. For example mymodule.py. To import that module so you can use it in other programs simply type import mymodule and then you can reference the functions in there.

#5 Glunn11

Glunn11
  • Topic Starter

  • Members
  • 262 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Idaho
  • Local time:05:06 PM

Posted 15 November 2006 - 11:00 PM

Alright cool I've got the functions/modules now (thanks)... but how about handling files?

#6 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:07:06 PM

Posted 16 November 2006 - 12:27 AM

NOt that familiar with file access in python. Cant help you on that one...just read through the material and create your own scripts to test with..you should be able to figure it out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users