๐Ÿค” If you are learning Python ๐Ÿ, I want to do an experiment:

Here's a thread ๐Ÿ‘‡๐Ÿงต teaching you conditional expressions.

BUT, I will teach you with NO words ๐Ÿ˜ถ

I will only show code snippets and examples.

Check the thread out carefully ๐Ÿ” and then give me your feedback!
By the way, if you want to learn something from this thread...

I'm not going to lie, you'll have to focus ๐Ÿ”.

Also, what's the rationale for this crazy ๐Ÿคช thread?

By reading code and examples, you see first-hand how the feature is used and where it comes in handy.

Let's go:
That is it for this thread.

So... How was it? ๐Ÿ˜‚
Did you learn something, or was this thread complete trash ๐Ÿšฎ?

Give me your honest feedback!

Just commenting a โœ… or โŒ is enough for me.

(Later today I'll publish this thread again, but with words ๐Ÿคฃ.)
If you are on a path to mastering Python ๐Ÿ, and if you want to keep improving your Python skills, then you will want to follow me โ€“ @mathsppblog.

I publish quality content daily that you won't want to miss!

See you around ๐Ÿ‘‹
For reference, here is (more or less) the same thread, with words:

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Rodrigo ๐Ÿ๐Ÿ“

Rodrigo ๐Ÿ๐Ÿ“ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mathsppblog

29 Sep
I challenged you ๐Ÿ†...

You delivered ๐Ÿ’ช!

I asked you to implement the sign function in Python ๐Ÿ.

Now I'll go over some alternatives and tell you what I like โœ… and dislike โŒ about them.

I'll also tell you which one I think is the best, most Pythonic โœจ one.

๐Ÿ‘‡๐Ÿงต Image
By the way, for reference, here is the original challenge:

Let's start with the โ€œbasicโ€ `if: ... elif: ... else: ...` approach first.

Gets the job done, is simple, and is easy to ready.

Funnily enough, the only one to share that solution was a _very_ seasoned Python ๐Ÿ programmer, author and trainer, @dabeaz ๐Ÿ™ƒ

Now, a couple of notes: Image
Read 28 tweets
28 Sep
Interested in improving your Python ๐Ÿ skills?

๐Ÿค” If you are, have you learned about conditional expressions?

Here is a MEGA thread ๐Ÿ‘‡๐Ÿงต teaching you almost everything there is to know about conditional expressions!

I will include a bunch of examples ๐Ÿ–ผ, so don't worry!
This is the follow-up to my experiment from earlier today.

I tried teaching you about conditional expressions without words ๐Ÿ˜ถ.

Here is the original thread:

Alright, so conditional expressions aren't that hard, really.

It is just an expression: a piece of code that evaluates to a result.

But then, it is tied to a condition: depending on whether the condition is truthy or falsy, the final result changes.

Check the function below:
Read 30 tweets
26 Sep
Have you heard that Python ๐Ÿ 3.10 will be released soon?

Are you ready for when it drops ๐Ÿ’ฃ๐Ÿ”ฅ?

Python 3.10 will ship with the new โœจ match statement, and I created a cheatsheet just for that.

This is also a thread ๐Ÿ‘‡๐Ÿงต that breaks it down and explains everything:
The cheatsheet is free and teaches you 12+ things about the new `match` statement.

From the basics, to object destructuring, to wildcards, among other things.

Get it from the link ๐Ÿ‘‡, and keep reading below to learn all about the `match` statement.

mathspp.gumroad.com/l/cheatsheet_mโ€ฆ
In its most basic form, a `match` statement kind of resembles an `if` statement.

That's what most of the โ€œswitchโ€ or โ€œmatchโ€ statements in other languages do: a series of `if` / `elif` / `else` statements.

Even a basic `case` is powerful: use `|` to separate multiple options. Image
Read 23 tweets
25 Sep
What's the BEST way to learn Python ๐Ÿ?

I've been writing Python for 10 years and taught 100s of people.

Here is a FAQ with actionable advice ๐Ÿ‘‡๐Ÿงต

But everyone is different, so share your thoughts as well ๐Ÿ‘‡๐Ÿ’ฌ to help as many as possible!
๐Ÿ โ€œHow do I start learning Python?โ€

Well, I think the answer to this question greatly depends on whether you have (considerable) programming experience with another language or not.

That's because โ€œlearning Pythonโ€ can mean โ€learn the syntax of the languageโ€, but...
... it can also mean โ€learn how to think like a programmerโ€.

And, in my opinion, this is something very fundamental that you have to understand!

Being a programmer is also about having that programmer mindset.

Worry not, you can learn it ๐Ÿ˜Š
Read 35 tweets
24 Sep
Do you want to master Python ๐Ÿ list comprehensions?

Do you want to become more proficient working with lists in Python ๐Ÿ?

If you answered with โ€œyesโ€, then here's a cheatsheet of mine to help you out.

This is also a thread ๐Ÿ‘‡๐Ÿงต that breaks it down and explains everything:
First off, here is the anatomy of a list comprehension.

There's 4 parts to a list comp:
1. enclosing brackets to create the list [];
2. expression that transforms your data;
3. `for` iteration over the initial data;
4. (optional!) condition to filter some data.
Do list comprehensions look confusing?

Maybe.

But that's because you didn't realise that list comprehensions have equivalent `for` loops!

The coloured boxes below show the equivalent bits in the list comp and in the `for` loop:
Read 19 tweets
23 Sep
Do you know what the Python ๐Ÿ `type` is?

But do you _really_ know what it is?

Here is a valuable thread that will give you insights into what `type` is and does.

Let's go ๐Ÿ‘‡๐Ÿงต
What does `type` do?

You might say that `type` takes an object and returns the type of the argument.

Here are some examples:
Fine, so `type` is a function!

Or is it..?

Take a look at the example above.

`sum` is a built-in function and `type(sum)` returned โ€œbuilt-in function or methodโ€.

So, logically, if `type` is a (built-in) function, the type of `type` should give the same thing:
Read 14 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(