Vous êtes sur la page 1sur 7

Python Assignment Help

For Python Programming Help/Python Homework Help


or Python Programming Project Help you can just upload
your Python Language Assignment/Python Language
Homework or Python Language Project at our website or
email it to support@locusrags.com Mr. Neil Harding with
his team of Online Python Programmers would go through
your requirements and would revert at the earliest.

You can schedule a one on one tutoring session with our


Online Python Tutors by discussing on our live chat.

Python was developed by Guido van Rossum. It is a


dynamic language, unlike C & Java, and is more flexible
than those languages but that comes with a performance cost. Python is ideal for writing short
scripts, as it has a lot of features built in to the language and libraries and can run without having
to compile the program first. Python 3 was released in 2008, but many people still use Python 2
since there are changes to the language which make it so that you need to change your code to
run. Python has classes, although you don't need to use them unlike Java. It supports lists as part
of the basic language these are similar to arrays in Java and C although they have some extra
features, such as the ability to select part of the list. It also has support for dictionaries which
allow you to retrieve items efficiently by name.

Python 2 : Python 2.7 is the most recent version of the Python 2, it has generators (which behave
like a list but only evalaute the value as they are needed). It has modules with support for
datatime calculations, large number support, file handling, persistent objects, database access,
compression, csv files, multithreading, sockets, email, html, xml, web, audio, and GUI. There are
also a lot of additional libraries available at pypy (http://pypi.python.org/pypi).

Python 3 : Python 3.3 is the most recent version of Python. A few of the main changes from
version 2 of Python are the / operator which now returns a floating point value rather than an
integer value, and the print command which is now a function, so you enclose the expression you
want to print in (), strings were changed to unicode. There is a program called 2to3 that helps
you convert programs written for Python 2 to Python 3.

Help on Python Programming Basics Python Programming Syntax, How to use an IDE
(Eclipse and Python Visual Studio), methods.

Introduction to Variables : strings, integers, lists and dictionaries.


Covers the basic types and the differences between them. How to declare a variable, including
the legal names, initializing lists and dictionaries and accessing them.
Comparison operators: <,>,==,!=,<=,>=
Loops and conditions : for loops, while loops, if then else, switch, case, break, continue, default
For loops consists of initializer, condition test, modifier and body each of these can be empty. A
while loop, can have a condition either at the start or the end of a loop. Switch statements allow a
range of values to be checked each with their own code to be executed if the value matches. If
then else statements allow for more complex expressions than a switch statement. There is also a
ternary operator, which uses if and else.
Comments: # and ''' (or """)
Python has # for single line comments, """ to mark a section of code as a
comment, which can be used by tools to provide documentation.
Operators: +,-,*,/,//,%,&,and,|,or,~,<<,>>,>>>,!,^:
Strings: capitalize, count, endswith, find, index, join, replace, split, startswith, strip, title,
translate format, Template,
Python strings are immutable (they can not be changed), but you can create a new string with the
operators and methods above. Strings allow for Unicode, so they can be used to support
languages such as Chinese and Japanese as well as English. You can use [] to select a substring,
so [start:end] will return the characters from start to end, if you don't include start then it defaults
to the beginning of the string, and if you don't include the end then it defaults to the end of the
string. You can use negative values to count back from the end of the string so [-1:] would be the
last character of a string.
Regular Expressions: re, compile, search, match, split, sub, findall, groups,
Python supports regular expressions, with + meaning one or more of the previous expressions,
and * meaning 0 or more of the previous expression. It also supports sets with [], and groups
with (), you can also use | to indicate or. There are also special codes for digits, alphabetical
characters, etc. Assistance with Intermediate Python Programming.
Modules : import, dir, from, globals, locals
A python package allows you to collect a group of files, so that they can be used with another set
of files without you needing to worry about naming conflicts.
Using Classes : class, object, None, __new__, __init__, __repr__, self, __hash__, __index__,
__del__, __getattr__, __setattr__, __delattr__, __lt__, __eq__, __ le__, __ge__, __gt__, __ne__
Python is a dynamic language, so the methods associated with an object may change whilst the
program is running unlike Java and C++. It also lacks the private keyword but if you start a field
with __ then it is treated as private (although this is done by renaming the variable, so it is still
possible to access it). You can define a class animal with behaviors such as noise, and then
define subclasses such as dog and cat. When you call the noise method it would "bark" or
"meow" depending on the type of animal. Because it is a dynamic language you can have
methods such as fly which would only be appropritate for birds and would not be present on non
flying animals.To access fields inside a method, you can use "self" to access the current object
(this is just a convention and you can change it to "this" if you want something more familiar if
you are used to C++ or Java). You create an instance of a class with the new operator, and that
calls the __init__ method for the class and allocates the memory. You can tell if an object is a
member of a class with isinstance.
Functions : def, static, arguements, lambda
Python supports methods with a variable number of arguements, you can use default values for
arguments. A static method does not need to refer to an existing object (you don't pass self to a
static method). You can store a function in a variable and call it via that variable (the same as
function pointers in C/C++). Lambda is used to define a short method that can be passed to a
routine.
Exception handling : try, except, else, finally, raise, with
Exceptions are a way of signalling errors, in C it was traditional to use error codes as return
codes from functions, but the value was often ignored. Exceptions provide a way of forcing the
error to be handled (or at least allows the system to display an error message if it is not caught).
The finally statement is used so that you can make, some code is called, even if an exception is
thrown. This can be used to close a file that has been opened, or a network connection to be
closed.
Collections : deque, Counter, defaultDict, Set, frozenSet
Python has a set of collection classes, which are similar to the STL in C++. Lists are built into
the language with the [] notation, and {} are used for dictionaries (the are called Maps in C &
Java). There is set which is used if you only need to know if a value is present or not, list which
maintains the order that elements are inserted, and dictionary which allows you to index the
items by a key. There are specialized versions such as deque which is a list with methods to
access it from either end. Counter is dictionary which keeps count of the number of instances of
a key, OrderedDictionary allows you to access the order the objects were inserted, and
defaultDictionary allows you to return a value for keys that are not present. You can iterate
through the contents of a collection, check whether a value is present with contains. You can use
len() find the size of a collection.
Handling Files : open, close, flush, read, readline, readlines, seek, tell, truncate, writelines

Python supports a rich variety of file handling, with the ability to read and write to files, to check
if a file exists, to delete a file, to create a directory. It uses exception handling to report on errors.
In the os module there is listdir to get the contents of a directory.Advanced Python Language
Programming support.

GUI: TKinter, WxPython, PyQt


Python supports some UI frameworks such as TKinter, WxPython, and PyQ that allow you to
write a Windows style application that is cross platform.
Threads: threading, multiprocessing, run, start, join, Lock, Event, Semaphore
It is hard to write an efficient multithreaded application that is thread safe(interaction between
threads means the results are not repeatable, so it may work one time but not the next, depending
on the order the threads execute in). When writing a multithreaded application, you need to deal
with atomic variables, syncronized code.
Networking: TCP, UDP, ports, socket, ssl, connect, bind, urllib2
Python supports both TCP and UDP sockets, which means it can be used to support realtime
internet applications as well as a web server, although if you are writing a web server you may
want to consider using a framework such as Web2py Django or the Google App Engine. urllib2
provides methods to interact with http connections and once you have a connection you can treat
it as though it were a local file and read or write from it (depending on the type of connection
you have). You can use sockets if you want to write a client/server application, such as a game or
a chat program.
Serialization: marshal, pickle, cPickle, dump, load, dumps, loads

You can save objects to a file or memory with pickle, it automatically handles references to other
objects to ensure that they are not stored multiple times. dump and load are used to save to a file,
where as dumps and loads are used to save to a string.

Sample questions we have answered before include:1-Create ir3.py based on ir2.py

2-Repeatedly prompt the user for a query (if they enter q, then quit)

3-Find the terms in the query, and calculate the appropriate weight for each query term (hint:) :
weight for query = log2 (total number of doc / number of times the word appear in all the Doc).
weight for query =((log( float( len( documents) ) / docfreq [ term ] ))/log(2))
the Output for the query quick brown vex zebrasshould be :

Term Weights

Quick 0.58
Brown 1.58

Vex 0.58

Zebras 1.58

4-Calculate the similarity for each query/document pair

(hint:) : the similarity= Q * D1 / |Q||D1| for example :

5-List the documents in order of decreasing similarity to the query, along with their similarity
value

Your results for quick brown vex zebras should be:


D1.txt 0.42, D3.txt 0.33, D2.txt 0.08

7-Make sure that querying quick brown vex zebras a 2nd time gives the same result

8-What is the result for the query quick brown vex lion?

Genral Hint :

For user Input :


while True:

querystring = raw_input( '\nEnter query (q to quit): ' )

if querystring == 'q':

print '\nGoodbye!\n'

break

do more stuff

To sort a dictionary in descending order by value from operator import itemgetter

items = results.items()

items.sort( key = itemgetter(1), reverse=True )

for (document, ranking) in items:

print document, "%.2f" % ranking

Please find the attached python code and data file. I need to code to be done ASAP. Output
should be in Fas file format.
Requirement:
1) Need to find all the unique sequences in the given file(Done already).
Note: we only look into sequence not the header for repetition.

2) change the header format and add count=(No of repeated sequences)


Note Sample : current header format is
>G7OSE5B06HOQHO|rank=0000003|x=3035.0|y=138.5|length=127|reverseBarcodePrimer|RC2
Required to change to
>G7OSE5B06HOQHO|count=?|reverseBarcodePrimer|RC2

3) Sort the unique sequence based on the count number of the header in descending order.
1) program should read the reference sequence and Read Sequence
2) User input from keyboard number and SAM cigar string.
3) use number and cigar value and align the sequence
4) write the output sequences into alignedoutput.fas file

Algorthim:
Steps involved:
Remove all the characters in reference string up to the number specified by the user:

Step-1
Example: user specified 5
Ref string= AAAAAAATTTTTTTCCCCCGGGGG
it will change to= AATTTTTTTCCCCCGGGGG

SAM cigar string details:


Once we have both reference string after step one.
Use the cigar string and do the modifications to read and ref sequences.
cigar format is number value and its operation (34S-291M-1D-27M-1I-9M)
S/H- mean remove the characters in both the strings up to that numeric value.
I- means add insrest '- ' at that place in reference string
D- means add '- ' at that place in read sequence string
M- means Do nothing
Once we end the length of cigar remove all other characters in both read and reference sequence
of equal length

I am attaching sample file and its values also user value is 2236
Cigar string is 34S291M1D27M1I9M for input.

program name sam2fas file


This is a Python based programming on Network and security systems....use python2.4 to do this
assignment...i have attached a zipped folder containing the assignment brief and it sources, as
well as some notes from lessons....hope you can do this..... please take in mind what its written in
red font....the deadline for this assignment is 28/11/2012 please help

This assignment involves writing two small Python scripts and a report. Before you start you
must download the file summarysheets.zip from the course web page, unzip it and print the
summary sheet with your name on it. The file Name Ver.pdf tells you which sheet has your name
on it. There are two parts to the assignment:
Part 1 Recovery of an encrypted word using a forward search attack.
A 5 character word consisting of random capital letters has been encrypted using the RSA
algorithm. The word was encrypted in two 24 bit blocks using the ASCII values of the characters
(6510 to 9010 ) and padding the last block with a space (ASCII 3210 ). Each block was formed
by concatenating the 8 bit binary patterns of each of the characters in the block. Thus creating
two 24--bit intergers (actually 23bit integers, as the MSB is zero). You are provided with the
public key used for the encryption and with the decimal values of the encrypted blocks see
your summary sheet. You are required to use a forward search using a Python dictionary/hash
table to recover the word that was encrypted.[25] Part 2 Decryption of a jpeg file that has
been encrypted using a Vernam cipher. Download the byte compiled Python module randbit.pyc
from the module web page. The function nextbit() in this module can be used to generate a
random bit stream using one of a series of different generators. Below is an example of its use to
generate and display 50 random bits.
import sys
from randbit import *
# for information on nextbit() type randbit.nextbit in the help environment # of idle or in the
standard python shell
seed = 98071
for i in range(50):
seed,bit = nextbit(7,seed) # call to nextbit, using generator 7, which returns
# a modified value of the seed and a 'random' bit
sys.stdout.write(bit)# print bit without crlf print
Output from above: 00000001011111110001011100011111100010001111000000
The seed and generator that you are to use in this part of the assignment are given in your
summary sheet. Extract your encrypted jpeg file (see summary sheet) from the archived file on
the module web page. Your jpeg has been encrypted, one byte at a time, with a Vernam cipher
using a random bit stream generated using the seed and generator that you have been assigned.
Random bytes were created by concatenating 8 bits at a time from the random bit stream, with
the MSB of each byte being the first of the 8 bits taken from the stream.
You are to decrypt and display the file, which should be a picture of three printable ASCII
characters.
NOTE: the Departmental machines are running Python 2.4 and randbit.pyc was complied with
this version of Python.

Your Scripts
1. Must be adequately commented and referred to in your report.
Your Report
1. MUST begin with the filled in Summary sheet provided.
2. For Part 1 it should explain what is meant by a forward search and show and explain all the
steps that you used to determine the word that had been encrypted.
3. For Part 2 it should show and explain how the supplied encrypted jpeg file was:
?? read;
?? decrypted; ?? written;
?? displayed.
?? Your report including your scripts should be word processed and be no more than SIX A4
pages (excluding the summary sheet) 12pt, sensible margins (i.e. about 2cm), one and a
half line spacing, and having a footer with the module number, your name and the page number.
?? You report should be stabled securely with the coursework receipting proforma and NOT
placed in a plastic wallet and then stapled.
?? If additional sources are used they must be clearly acknowledged and fully and properly
referenced.
?? The report must be in YOUR OWN WORDS except of course for any quotations. ?? The
normal Faculty handing in procedure should be adopted.

Vous aimerez peut-être aussi