Python Cheat Sheet

Python Cheat Sheet: Python is an easy-to-learn, powerful programming language […] Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development.

We all need to start somewhere:

Python Cheat Sheet
Python Cheat Sheet

Variables
We use variables to temporarily store data in the computer’s memory.
price = 10
rating = 4.9
course_name = ‘Python for Beginners
is_published = True
In the above example,
• price is an integer (a whole number without a decimal point)
• rating is a float (a number with a decimal point)
• course_name is a string (a sequence of characters)
• is_published is a boolean. Boolean values can be True or False.

Comments
We use comments to add notes to our code. Good comments explain the hows and whys, not what the code does. That should be reflected in the code itself. Use comments to add reminders to yourself or other developers or also explain your assumptions and the reasons you’ve written code in a certain way.

# This is a comment and it won’t get executed.
# Our comments can be multiple lines. 

Variables 5 ……………………………………………………………………………………..
Comments 5 …………………………………………………………………………………….
Receiving Input 5 …………………………………………………………………………….
Strings 6 …………………………………………………………………………………………
Arithmetic Operations 7 …………………………………………………………………..
If Statements 8 ………………………………………………………………………………..
Comparison operators 8 ………………………………………………………………….
While loops 8 …………………………………………………………………………………..
For loops 9 ………………………………………………………………………………………
Lists 9 ……………………………………………………………………………………………..
Tuples 9 …………………………………………………………………………………………..
Dictionaries 10 …………………………………………………………………………………
Functions 10 …………………………………………………………………………………….
Exceptions 11 ……………………………………………………………………………………
Classes 11 …………………………………………………………………………………………
Inheritance 12 …………………………………………………………………………………
Modules 12 ………………………………………………………………………………………
Packages 13 ……………………………………………………………………………………..
Python Standard Library 13 …………………………………………………………….
Pypi 14 ……………………………………………………………………………………………
Want to Become a Python Expert? 14

1 thought on “Python Cheat Sheet”

Leave a Comment