Download Python

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Go (programming language) wikipedia, lookup

Object-oriented programming wikipedia, lookup

C Sharp (programming language) wikipedia, lookup

C Sharp syntax wikipedia, lookup

Programming language wikipedia, lookup

Java performance wikipedia, lookup

Java (programming language) wikipedia, lookup

Program optimization wikipedia, lookup

Python (programming language) wikipedia, lookup

Name mangling wikipedia, lookup

C syntax wikipedia, lookup

Control flow wikipedia, lookup

One-pass compiler wikipedia, lookup

Scala (programming language) wikipedia, lookup

Interpreter (computing) wikipedia, lookup

Resource management (computing) wikipedia, lookup

Comment (computer programming) wikipedia, lookup

String literal wikipedia, lookup

Reserved word wikipedia, lookup

Python syntax and semantics wikipedia, lookup

ALGOL 68 wikipedia, lookup

Perl 6 wikipedia, lookup

Transcript
Python
Henry Armstrong
Andy Burras
Everett Hite
History
• First released in 1991 by Guido van Rossum
• Designed around a philosophy which emphasized readability and
importance of programmer effort over computer effort
• Minimalist syntax and semantics
• Large standard library is comprehensive
• It was influenced by ALGOL 68, C, Lisp, Perl and Java
• It was originally developed for UNIX scripting, but eventually grew
beyond these bounds
Concepts
• Multi-paradigm language focusing on functional, object oriented and
imperative
• Has a fully dynamic type system. This means that type checking is
done during runtime
• Variables are strongly typed. This forbids operations which make
little or no sense (i.e.; cannot perform int + char)
• Has automatic memory management
• Has a highly readable, uncluttered language. Uses many English
keywords where other languages use punctuation
Implementations
• YouTube and the original BitTorrent client were programed in
python.
• Google and NASA use python for a variety of things
• Python is embedded in a number of software packages including
ArcGIS (a GIS package) and Maya (a high-end 3D animation
package)
• Python is also used for scripting in a number of video games,
including Civilization IV, Eve Online and Battlefield 2
Code Example
print "This is a factorial program.“
n = -1
#Initialize n for error checking
while n < 0:
#Ensure that only nonnegative numbers will be accepted
n = input( "What number do you want to factorialize?" )
temp = n
count = n – 1
#Initialize return value (temp) and the counter
if n == 0:
temp = 1
count = 0
#Account for special case 0! = 1; set temp, count to 1
while count > 0: #Calculate n factorial
temp = temp * count
count = count – 1
print n,"! =",temp #Print result
Comparison to Other Languages
The following programs will count from 0 to 1000000
and print them out to a file
Python:
f=open(‘/tmp/scratch’,’wb’)
For i in xrange(1000000):
f.write(str(i))
f.close()
C++:
#include <iostream.h>
#include <fstream>
using namespace std;
int main(int argc, char *argv[]){
ofstream out;
out.open("/tmp/scratch");
for(int i = 0; i < 1000000;
i++){
out << i;
}
out.close();
}
Java:
import java.io.*;
public class test{
public static void main(String[] args){
try{
File f = new File("/tmp/scratch");
PrintWriter pw = new PrintWriter(new BufferedWriter(
new FileWriter(f)));
for(int i = 0; i < 1000000; i++){
pw.print(i);
}
pw.close();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
}
Comparisons (cont’d)
To Java:
• Python typically run slower than equivalent Java programs
• The development process for Python is significantly shorter than that of Java
• Actual code length of Python is 3-5 times shorter than equivalent Java code
To C++:
• Python compared to C++ is similar to Python compared to Java, just to a greater
extent.
• Actual code length of Python is 5-10 times shorter than equivalent C++ code
• Python is sometimes referred to and used as a glue language that combines several
component written in C++
To Perl:
• Both share similar roots (Unix, scripting), and similar features.
• Perl is harder to maintain based off the sometimes cryptic syntax and multiple
operators
SOURCES
http://www.razorvine.net/python/PythonComparedToJava
http://www.wikipedia.com/Python_(programming_language)
http://furryland.org/~mikec/bench
http://www.python.org