Advertisement Β· 728 Γ— 90

Posts by

Post image

Want to play some music 🎢🎡 in #Python? Check out the 3rd-party VLC package!

1 day ago 1 0 0 0
Post image Post image

How to get the absolute value of a number + a BONUS how to get the magnitude of a complex number in #Python using the built-in `abs()` function

1 day ago 3 0 0 0
Post image

Need to convert RGB ro HSV or vice-versa in #Python? Try the colorsys module!

1 day ago 1 0 0 0
Post image

What is the fastest way to create an empty dictionary in #Python? Using `timeit` to find out:

5 days ago 2 0 0 0
Post image

How to change the compression of a JPEG image during saving with #Python and Pillow using only THREE lines of code! πŸπŸ–Ό

5 days ago 2 0 0 0
Post image

A silly example of using a #Python lambda and `filter()` to find multiples of four

5 days ago 0 0 0 0
Post image

How to use borb to create a simple PDF with #Python

1 week ago 3 0 0 0
Post image

How to get information from the user on the command line with #Python using the built-in `input()` function:

1 week ago 0 0 0 0
Post image

How to use #Python's `textwrap` to control multi-line string wrapping 🐍πŸ”₯

1 week ago 3 0 0 0
Post image

#Python includes a handy built-in function called `exec()` that can execute arbitrary code

Never expose your APIs to this or the related `eval()` function since that could allow people to harm your computer!

1 week ago 0 0 0 0
Advertisement
Post image

How to combine two iterables quickly in #Python using the `zip()` function:

1 week ago 3 0 0 0
Post image

What do you use #Python's walrus operator for? πŸβ“

Here's a popular example of its usage:

1 week ago 1 0 0 0
Post image

Have you used #Python's `divmod()` function before?

If not, `divmod()` takes two numbers as arguments and returns a tuple containing their quotient and remainder in a single operation

1 week ago 2 0 0 0
Post image

Need a random number in #Python? Try the `random` module!

1 week ago 0 0 0 0

I hope you enjoyed learning about #Python string formatting using the `format()` method

Be sure to follow me for more Python tips and tricks! 🐍πŸ”₯

2 weeks ago 0 0 0 0
Post image

The `format()` method also allows you to set the string alignment.

Here are a few examples:

2 weeks ago 1 0 1 0
Post image

If you put integers within the curly braces, then you can control which argument goes where (although this is probably the most confusing way to do it)

2 weeks ago 0 0 1 0
Post image

You can also just use named parameters and skip the dictionary:

2 weeks ago 0 0 1 0
Post image

You can also use a #Python dictionary when using the `format()` method to use named parameters:

2 weeks ago 0 0 1 0
Post image

What happens when you have too many braces, though?

Well, you get an error! 🐍⚠

2 weeks ago 0 0 1 0
Advertisement
Post image

When you use `format()`, you still use curly braces in your string. Then you pass in the same number of arguments as you have braces:

2 weeks ago 0 0 1 0

Before #Python f-strings, you had to call format()

Sometimes you still do, so it's good to learn about it!

Check out this mini thread on the topic

πŸπŸ§΅πŸ‘‡

2 weeks ago 1 0 1 0
Post image Post image

How to creae a pie chart with a popped out section using #Python and #matpllotlib 🐍πŸ”₯

2 weeks ago 1 0 0 0
Post image Post image

How to add multiple figures with #Python and #matplotlib

2 weeks ago 0 0 0 0
Post image Post image

How to add a legend to a bar chart using #Python and #matplotlib 🐍πŸ”₯

2 weeks ago 1 0 0 0
Post image

Did you know you can create your own custom iterators in #Python?

All you need to do is write your own custom `__iter__` and `__next__` methods

Here's an example:

2 weeks ago 3 0 0 0
Preview
Python Pop Quiz - Number Explosion - Mouse Vs Python You will sometimes come across examples of code that use one or two asterisks. Depending on how the asterisks are used, they can mean different things to Python. Check your understanding of what a single asterisk means in the following quiz! The Quiz What will be the output if you run this code? numbers = […]

You can check out one of them here:

blog.pythonlibrary.org/2026/04/02/...

2 weeks ago 1 0 0 0

I have started posting #Python Pop Quizzes in my newsletter and on my blog @mousevspython πŸβ“

These quizzes include the answers too!

2 weeks ago 1 0 1 0
Post image

#Python lambda craziness 🐍πŸ€ͺ

It's lambdas all the way down!

2 weeks ago 0 0 0 0
Advertisement
Post image

How to check if a string is printable or not in #Python 🐍🀯

2 weeks ago 2 0 0 0