Python basics cheat sheet
Welcome to your Python basics cheat sheet! This handy guide is designed to help you quickly and easily reference some of the most commonly used concepts and commands in Python programming. Python is a powerful, versatile and widely used programming language, that is known for its simplicity, readability and ease of use.
Python was first developed by Guido van Rossum in the late 1980s and it was designed to be easy to learn and easy to read. It quickly gained popularity and nowadays it’s used in a wide range of applications such as web development, machine learning, data science and many more.
Python offers a variety of features that make it an ideal language for beginners, including its simple and intuitive syntax, large standard library, and built-in support for common data types and structures.
This cheat sheet will cover the essential concepts and commands of Python programming, including variables, data types, operators, control flow, and more. Whether you’re just starting out on your coding journey or looking for a quick refresher, this cheat sheet has got you covered. So, let’s dive in and start exploring the world of Python programming together!
float(floating point number)
x = 5 y = "hello" z = True
+ : addition - : subtraction * : multiplication / : division % : modulus (remainder) ** : exponentiation // : floor division += : increment by a value -= : decrement by a value
== : equal to != : not equal to < : less than > : greater than <= : less than or equal to >= : greater than or equal to
and : logical and or : logical or not : logical negation
is : true if the operands are identical (refer to the same object) is not : true if the operands are not identical (do not refer to the same object)
in : true if the value is found in the sequence (e.g. list, string, tuple) not in : true if the value is not found in the sequence
& : bitwise and | : bitwise or ^ : bitwise xor ~ : bitwise inversion << : left shift >> : right shift
= : assigns values += : adds and assigns -= : subtracts and assigns *= : multiplies and assigns /= : divides and assigns %= : takes modulus and assigns **= : takes exponent and assigns //= : takes floor division and assigns
my_list = [1, 2, 3, 4, 5] my_list.append(6) my_list.remove(4)
# For loop for i in range(10): print(i) # While loop i = 0 while i < 10: print(i) i += 1
x = 5 if x > 0: print("x is positive") elif x < 0: print("x is negative") else: print("x is zero")
def add_numbers(x, y): return x + y result = add_numbers(3, 4) print(result)
And there you have it, a comprehensive overview of some of the most important Python basics. Whether you’re a beginner or an experienced coder, this cheat sheet is a valuable tool to have on hand as you continue to learn and grow in the world of Python programming. Keep it handy and refer back to it as needed. Happy coding!
Tools I use for this site
- I buy all my domain names on Namecheap, as thetrendycoder.com
- The hosting of this website is made on Bluehost.
- The website is created with WordPress.org (and not WordPress.com).
- I use the page builder Elementor because it makes it easy to create modern pages with drag and drop.
- I have multiple websites, and on most of them, I use themes from wpKoi. I love their design, they are very original and work well with Elementor.
- All the designs and images are created using canvas.
- I use Grammarly and languagetool to correct all my spelling and grammar mistakes.
- SEO is a big thing on a website, I use a WordPress plugin called YoastSEO to help me with the basic analysis. I also use a tool called Keysearch for choosing the right keywords.
- To handle affiliate links, I use two platforms: impact and ShareASale.
You want to write on TheTrendyCoder ?
If you are interested in publishing guest articles on this website, sharing your experience or coding tutorials, apply through this form.
NO EXPERIENCE needed!
NO PERFECT English needed!
NO DEGREE needed!
NO AGE limits!
No matter at what stage we are in our tech journey, we all have learned things and experienced things. Sharing them can help others and even help us. So, if you are a student, a professional, or a self-taught coder, feel at home and share some of your knowledge with the community.