Presentation is loading. Please wait.

Presentation is loading. Please wait.


Similar presentations

Presentation on theme: "PYTHON PROGRAMMING LANGUAGE."— Presentation transcript:


2 Python is a general-purpose interpreted, interactive, object- oriented and high-level programming language. Python was created by Guido van Rossum in the late eighties and early nineties. Like Perl, Python source code is also now available under the GNU General Public License (GPL). INTRODUCTION

3 First download Python- 2.4.1.exe by following this link. If you are a dialup user, keep in mind that the file is around 10MBPython- 2.4.1.exe Run the file you just downloaded, and follow the prompts. OK! Hopefully now everything is good! Now, to test if that just worked, type this in your DOS window: python –V INSTALLING PYTHON

4 Multiplication >>>5*2 10 >>>3**2 9 Division >>>21/7 3 Addition >>>1+1 2 >>>20+80 100 Subtraction >>>6-4 2 MATH IN PYTHON

5 #Variables Variables store a value, that can be looked at or changed at a later time. #Variable demonstrated print “this program is demo of variables” Print “ the value of v is now ”, v V=v+1 Writing program in python to a file is very easy. Python programs are simply text documents. You can open them up in notepad. #A simple program print “Mary has a little lamb” PROGRAM IN A FILE, AND VARIABLES

6 The “while” loop a=0 While a<10: a=a+1 Print a LOOPS

7 Basically, the for loop does something foe every value in a list. The way it is set out is a little confusing, but otherwise is very basic. #cheerleading program Word = raw_input(“ who do you go for? ”) For letter in word: Call = “Gimme a “ + letter + “!” Print call Print letter + “!” Print “what does that spell?” Print word + “!” FOR LOOP

8 If {conditions to b e met}: {do this} {and this} [but this happens regardless} {because it is not indented} Example1: Y = 1 If y = = 1 Print ‘y still equals 1, I was just checking” CONDITIONAL STATEMENTS

9 Python has lot of pre- made functions, that you can use right now, simply by ‘calling’ them. ‘Calling’ is a function involves you giving a function input, and it will return a value as output. Here is a general form that calling a function takes. function_name(paramet ers) FUNCTIONS

10 To open a text file you use, well, the open() function. Seems sensible. You pass certain parameters to open() to tell it in which way the file should be opened –’r’ for read only and –’w’ for writing only, -’a’ for appending and ‘r’+ both reading and writing. Ex- openfile = open(‘pathtofile’, ‘r’) FILE I/O



Similar presentations

Ads by Google