Python vs Julia Cheatsheet
- Comments
- Casting
- Null
- Tuples
- Functions
- Arrays
- Matrices
- Dictionaries
- Strings
- f strings/String interpolation
- Conditionals
- Logic
- Loops
- List comprehension
- Exceptions
- Assertions
- Counting
- Ternary operator
- Scoping
- Iterables
- url requests
Comments
Python | Julia | |
---|---|---|
Code |
Casting
Python | Julia | |
---|---|---|
Code | ||
Output | 9.0 |
9.0 |
Null
Python | Julia | |
---|---|---|
Code |
Tuples
Python | Julia | |
---|---|---|
Code | ||
Output |
Functions
Function
Python | Julia | |
---|---|---|
Code | ||
Output |
Lambda functions/Anonymous functions
Python | Julia | |
---|---|---|
Code | ||
Output |
Function arguments - Default
Python | Julia | |
---|---|---|
Code | ||
Output |
Arrays
Array/Vector
Python | Julia | |
---|---|---|
Code | ||
Output |
Array - append
Python | Julia | |
---|---|---|
Code | ||
Output |
Array - concatenation
Python | Julia | |
---|---|---|
Code | 1. vcat 2. reduce and vcat 3. append! | |
Output |
Array - Slicing
Python | Julia | |
---|---|---|
Code | ||
Output | ||
Code | ||
Output | ||
Code | ||
Output | ||
Code | ||
Output |
Array - Reshape
Python | Julia | |
---|---|---|
Code | ||
Output |
Matrices
Python | Julia | |
---|---|---|
Code | ||
Output | ||
Code | ||
Output |
Matrices - Transpose/Adjoint
Python | Julia | |
---|---|---|
Code | ||
Output |
Matrix muliplication
Python | Julia | |
---|---|---|
Code | ||
Output |
Broadcasting
Python | Julia | |
---|---|---|
Code | ||
Output |
Dictionaries
Python | Julia | |
---|---|---|
Code | ||
Output |
Strings
Strings or Chars?
Python | Julia | |
---|---|---|
Code | ||
Output |
Strings - Indexing
Python | Julia | |
---|---|---|
Code | ||
Output |
Strings - Concatenation
Python | Julia | |
---|---|---|
Code | 1. .join 2. + operator | 1. string 2. * operator |
Output |
Strings - Length
Python | Julia | |
---|---|---|
Code | ||
Output |
Strings - Regex
Python | Julia | |
---|---|---|
Code | ||
Output |
f strings/String interpolation
Python | Julia | |
---|---|---|
Code | ||
Output | This substitutes 9.0 |
This substitutes 9.0 |
Conditionals
Python | Julia | |
---|---|---|
Code |
Logic
Python | Julia | |
---|---|---|
Code | ||
Output |
Loops
While loops
Python | Julia | |
---|---|---|
Code | ||
Output |
For loops
Python | Julia | |
---|---|---|
Code | ||
Output |
List comprehension
Python | Julia | |
---|---|---|
Code | ||
Output |
Exceptions
Python | Julia | |
---|---|---|
Code | ||
Output |
Assertions
Python | Julia | |
---|---|---|
Code | assert 8 == 1 |
@assert 8 == 1 |
Output | AssertionError |
ERROR: AssertionError: 8 == 1 |
Counting
Python | Julia | |
---|---|---|
Code | ||
Output |
Ternary operator
Python | Julia | |
---|---|---|
Code | ||
Output |
Scoping
Python | Julia | |
---|---|---|
Code | ||
Output |
Iterables
map
Python | Julia | |
---|---|---|
Code | ||
Output |
zip
Python | Julia | |
---|---|---|
Code | ||
Output |
enumerate
Python | Julia | |
---|---|---|
Code | ||
Output |
url requests
Python | Julia | |
---|---|---|
Code |