Python Comparison
From Processing
Python is considered to be an excellent teaching language because of its clear syntax and structure. Python is typically used for non-graphic applications. It doesn't have a native graphics library, but graphics applications may be created by using graphics toolkits, some of which are cross-platform.
Python is the product of a community effort, rather than a corporate project. Python was originated by the benevolent dictator Guido van Rossum. The language is characterized by a small syntax and huge variety of modules which extend the possibilities of the language.
| Data | |
|---|---|
| Processing | Python |
| int x = 70; // Initialize x = 30; // Change value | x = 70 # Initialize x = 30 # Change value |
| float x = 70.0; x = 30.0; | x = 70.0 x = 30.0 |
| int[] a = {5, 10, 11}; a[0] = 12; // Reassign | # For this simple comparison, a "list" in python # may be used like the "array" example in # Processing shown to the left. A "list" in python # is more similar to an ArrayList in Processing # than a primitive array a = [5, 10, 11] # Create a list a[0] = 12 # Reassign |
| Control | |
| Processing | Python |
| // In Processing, draw() is called repeatedly, // acting like an infinite while loop // whose condition is always true. void draw() { // Statements } | while 1: # Statements |
| while (a < 10) { // Statements } | while a < 10: # Statements |
| for (int a = 0; a < 55; a++) { // Statements } | for a in range(55): # Statements |
| for (int a = 45; a < 55; a++) { // Statements } | for a in range(45, 55): # Statements |
| if (c==1) { // Statements } | if c == 1: # Statements |
| if (c!=1) { // Statements } | if c != 1: # Statements |
| if (c < 1) { // Statements } | if c < 1: # Statements |
| if (c >= 1) { // Statements } | if c >= 1: # Statements |
| if ((c >= 1) && (c < 20)) { // Statements } | if c >= 1 and c < 20: # Statements |
| if (c >= 20) { // Statements 1 } else if (c == 0) { // Statements 2 } else { // Statements 3 } | if c >= 20: # Statements 1 elif c == 0: # Statements 2 else: # Statements 3 |
This translation was created by Walter Aprile, jc-denton, and toxi.