Python Cheatsheet

The next step I wanted to take was to create my first trading strategy with an edge. I already had some ideas so I wanted to backtest them in MT4. I already knew how to build and optimize trading strategies in MT4 using MQL programming language, but I also knew that MT4 optimization is very slow. This wasn’t a problem for me until know.

I needed something fast, so I’ve decided to start learning Python. Since I already have almost 15 years of programming experience, I thought that learning Python will be easy. The language itself is quite simple, but some parts of syntax are quite confusing in the beginning, so I’ve made my own Python Cheatsheet.

NOTE: “In[]” means input and “Out[]” represents what is the output of the code.


Math Operators:



Note: Strings allow both single quotes and double quotes.


List Indexes:


Nested List:


Boolean Values:

Tuple Data Type:

The main difference between tuples and lists is that tuples are unchangeable.


Set is an unordered collection with no duplicate elements.

Importing Modules:

Use TAB to enable autocomplete.

Comparison Operators:

These operators evaluate to True or False.

Logical operators:

RELATED POST  Hello everyone! This is my first post on

They allow you to combine multiple comparison operators

if/else/elif Statements:

for Loops:

while Loops:



Lambda expressions/functions:

Lambda function is an anonymous function which is usually used once.

map Function:

filter Function:

string Methods:

I hope that this Python Cheatsheet will be useful to you.

Subscribe for FREE and get the following:

  • Free Excel Templates and printable PDFs for your Money Saving Challenges
  • Free MT4 indicator which I used to earn 18% of my trading account in only 3 months
  • Useful trading, investing and money saving tips
  • Weekly list of websites & articles which will expand your knowledge and teach you how to spend less and earn more
  • Updates on new posts on my blog
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *