11
www.myassignmenthelp. net PYTHON PROGRAMMING LANGUAGE

Python Assignment & Homework Help

Embed Size (px)

DESCRIPTION

Python is Widely used Programming Language nowdays and the University and High School Assignments and Homework are the Part of the Curriculum. So with the help of Online Tutoring Service of myassignmenthelp you can achieve your Goals at the Right Time

Citation preview

Page 1: Python Assignment & Homework Help

www.myassignmenthelp.net

PYTHON PROGRAMMING

LANGUAGE

Page 2: Python Assignment & Homework Help

• 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

Page 3: Python Assignment & Homework Help

• 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 10MB

• 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

Page 4: Python Assignment & Homework Help

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

Page 5: Python Assignment & Homework Help

• #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

Page 6: Python Assignment & Homework Help

• The “while” loop

a=0

While a<10:

a=a+1

Print a

LOOPS

Page 7: Python Assignment & Homework Help

• 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

Page 8: Python Assignment & Homework Help

• 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

Page 9: Python Assignment & Homework Help

• 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(parameters)

FUNCTIONS

Page 10: Python Assignment & Homework Help

• 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’)

Openfile.read()

FILE I/O

Page 11: Python Assignment & Homework Help

ANY QUERY

WWW.MYASSIGNMENTHELP.NET