19
Python assignment help www.myassignmenthelp.n

Python assignment help

Embed Size (px)

Citation preview

Page 1: Python assignment help

Python assignment help

www.myassignmenthelp.net

Page 2: Python assignment help

What is Python

• Multi-purpose i.e, Web, Graphical user interface

(GUI), Scripting and many others.

• Strongly typed as well as dynamically typed.

• Focus on readability as well as productivity.

• Object oriented.

• Interpreted.

www.myassignmenthelp.net

Page 3: Python assignment help

Characteristics

• Easy to Learn • High-level Language• Interactive shell• Strong introspection• Cross platform• Object Oriented• Everything is an object• Free and Open Source

www.myassignmenthelp.net

Page 4: Python assignment help

CONT..• Useful built-in types (lists, dictionaries)• Clean syntax, powerful extensions• Interpreted• Interactive• Commonly used for producing HTML content on

websites. Great for text files• Functional• Extensive Libraries

www.myassignmenthelp.net

Page 5: Python assignment help

Languages

www.myassignmenthelp.net

• Few important types:– FORTRAN• Technology

– COBOL• Business Information

– LISP• Logic as well as AI

– BASIC• Easy Language

Page 6: Python assignment help

The Python Interpreter

• Python can be an interpreted terminology

• The actual interpreter has an interactive environment in order to perform using the language

• Results

>>>> 4 + 59>>>> 4 < 15 True>>>> “print me”“print me”>>>> print “print me”print me>>> >

www.myassignmenthelp.net

Page 7: Python assignment help

Print “Hello World”

• Open a terminal window and type ‘python’• If on Windows open a Python IDE such as IDLE• At the prompt type “Hello World !!”

>>>> ‘Hello World !!'

‘Hello World !!'

www.myassignmenthelp.net

Page 8: Python assignment help

The print Statement

>>>> print “Welcome”Welcome>>>> print “Welcome”, “Ram”Welcome Ram

• Elements divided through commas , print with a space between them• The comma at the end from the statement (print “Welcome”,) won't printing the new line character

www.myassignmenthelp.net

Page 9: Python assignment help

The Documentation

>>> > “welcome'

‘welcome'

>>> #‘comment'

>>>

‘#’ : this symbol is used for starts a comment

www.myassignmenthelp.net

Page 10: Python assignment help

Variables• Do not need to declare• Should determine (initialize)

• Using uninitialized variable improves exception

• Certainly not typedin case ,friendly: greeting = “Hello World"else: greeting = 12**2print greeting

• Anything is often a ‘variable’:• Even characteristics, classes, modules

www.myassignmenthelp.net

Page 11: Python assignment help

Everything is an object

• Everything means, which includes functions as well as classes

• Data type is usually a property of the object instead of on the variable

>>>> x = 9>>> x9>>>> x = “Welcome”>>>> x“Welcome” >>>>

www.myassignmenthelp.net

Page 12: Python assignment help

Interactive “Shell”• This is good for learning the language• Good for experimenting for using your library• Good for testing for using your own modules• 2 variants: IDLE (GUI),

python (command line)• Kind statements or even expressions at prompt:

www.myassignmenthelp.net

>>>> print "Hello, World"Hello, World>>>> x = 12**2>>>> x/272>>>> # (this is a comment)

Page 13: Python assignment help

Numbers• The typical suspects:

• 13, 3.15, 0xFF, 0377, (-1+2)*3/4**5, abs(x), 0<x<=5• C-style shifting & masking:

• 1<<17, x&0xff, x|1, ~x, x^y• Integer division truncates:

• 1/2 -> 0 # 1./2. -> 0.5, float(1)/2 -> 0.5• fixed in the future

• Long complicated:• 2L**100 -> 1267650600228229401497607505376L–Within Python 2.2 as well as past, 2**100 will the

same

www.myassignmenthelp.net

Page 14: Python assignment help

Strings• ‘Hello’+ ‘World’ ‘HelloWorld’ # Concatenation• ‘Hello’*2 ‘HelloHello’ # Repetition• ‘Hello’[0] ‘h’ # Indexing• ‘Hello’[-1] ‘o’ # (From end)• ‘Hello’[1:4] ‘ell’ # Slicing• len(‘Hello’) 5 # Size• ‘Hello’< ‘jello’ 1 # Comparison• ‘e’ in ‘hello’ 1 # Search• ‘escapes: \n etc, \033 etc, \if etc’• 'single quotes' """triple quotes""" r ‘raw strings’

www.myassignmenthelp.net

Page 15: Python assignment help

Lists

• Variable arrays, definitely, not Lisp-like linked lists

• x = [99, [‘on’, ‘the’, ‘wall’]]

• Exact same providers for strings• x+y, x*3, x[0], x[-1], x[1:], len(x)

• Item and slice assignment• x[0] = 98

-> [98, [‘on’, ‘the’, ‘wall’]]• del x[-1] # -> [98]

www.myassignmenthelp.net

Page 16: Python assignment help

Tuples

• Tuples tend to be immutable versions associated with lists

• One strange may be the structure to create a tuple along with one element:‘,’ is required to differentiate from the numerical expression (2)

>>>> a = (1,2,3)>>> >a[1:](2, 3)>>>> b = (2,)>>> >b(2,)>>> >

www.myassignmenthelp.net

Page 17: Python assignment help

Dictionaries

• Some key-value sets• Dictionaries tend to be mutable

>>> x = {1 : ‘Welcome', ‘Two' : 32, ‘Hi' : [4,5,6]}>>> x{1: ‘Welcome', ‘Two': 32, ‘Hi': [1, 2, 3]}>>> x[‘Hi'][4,5,6]

www.myassignmenthelp.net

Page 18: Python assignment help

Standard Library• Core:– operating system, sys, string, StringIO, struct, pickle etc

• Regular expressions:– re module, Perl-5 style patterns as well as matching

rules• Web:– socket, rfc822, httplib, htmllib etc

• Miscellaneous:– pdb – Tkinter, audio etc

www.myassignmenthelp.net

Page 19: Python assignment help

Thank You

www.myassignmenthelp.net