Stephen Gruppetta Profile Banner
Stephen Gruppetta Profile
Stephen Gruppetta

@s_gruppetta_ct

Followers
9,357
Following
656
Media
1,719
Statuses
17,543

Constantly looking for simple ways to explain complex things in Python • Here, you'll find Python stuff and my views on narrative technical writing…

Joined October 2019
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
Pinned Tweet
@s_gruppetta_ct
Stephen Gruppetta
7 days
Stories are everywhere. They've been an integral part of human societies for ever. There’s a reason for it. Stories engage. They tap into emotions. They convey messages better than raw facts. They lower a reader’s cognitive load, helping them understand better and recall what
Tweet media one
0
1
1
@s_gruppetta_ct
Stephen Gruppetta
6 months
@tunguz The one you're buying next month stopped working today
2
3
2K
@s_gruppetta_ct
Stephen Gruppetta
2 years
What's an image made of? There are many correct answers. But the most fascinating one is: << sines & cosines >> Read on if you're intrigued👇🧵🪡 #python #images #fourier
15
122
486
@s_gruppetta_ct
Stephen Gruppetta
2 years
I know many schools are using The Python Coding Book and its tutorials for teaching Python Although this content was written with adult learners in mind, a lot of the work I do daily involves teaching kids, so glad to see schools use this resource Some highlights 👇
19
100
433
@s_gruppetta_ct
Stephen Gruppetta
2 years
Are `a = []` and `a = list()` the same? How about `a = a[::-1]` and `a.reverse()`? Let's look as some list operations to see whether they're the same or not… Read more… 👇🪡🧵 #python #programming /1
13
72
383
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 5: Inheritance --- The students are growing up! This Year they'll learn about a key property of OOP - how to create a class that inherits from another one Here's the code so far /1
Tweet media one
6
68
363
@s_gruppetta_ct
Stephen Gruppetta
2 years
#Matplotlib is not just for displaying data… …here I use it for a fun simulation of planets orbiting a sun (or many suns, see next tweet) Here's the article if you're looking for a step-by-step tutorial: #python #planets @matplotlib
8
61
347
@s_gruppetta_ct
Stephen Gruppetta
2 years
So, you've never accessed data over the internet using an API and don't know where to start? Start with the simplest option… The World Bank site has some free data with an easy to use API Here's an example using the `requests` library 👇🪡🧵
5
66
332
@s_gruppetta_ct
Stephen Gruppetta
2 years
The way Python deals with variables is different from some other languages. You may even have heard some say they're not technically variables Let's visualise what's happening when you create a name in Python and assign data to it with The Box and Label analogy /1
Tweet media one
Tweet media two
20
63
332
@s_gruppetta_ct
Stephen Gruppetta
2 years
A small headache for learners is knowing how to format their code In Python, some of this matters as it's part of the syntax But other aspects of formatting are linked to style rather than syntax and can confuse those learning to code Let's dive further into this /1
Tweet media one
13
52
318
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 8 in the Python functions series Yesterday we saw the "rogue" forward slash in the function definition. Today, it's the "rogue" asterisk or star * def greet(host, *, guest): Let's look at keyword-only arguments today /1
Tweet media one
11
43
275
@s_gruppetta_ct
Stephen Gruppetta
2 years
Back to basics: what do sine and cosine really mean? This is a mini-project using turtle I do with secondary school children who have learnt about sines and cosines but don't **really** know what they are. I'm debating whether to write this as a… #python #coding 1/
14
47
263
@s_gruppetta_ct
Stephen Gruppetta
2 years
One of the most underrated #Python modules? `turtle` We know it's used for teaching & not in the "real-world" But it's usually used only for basic drawings & simple animations for kids–a very limited scope We can teach more advanced topics, too… Here are some examples… /1
10
51
244
@s_gruppetta_ct
Stephen Gruppetta
2 years
Let's write this game in 20 tweets… Yes, just 20 Ready? Go… • Balls appear in random positions every few seconds and are tossed upwards with random velocities • Click close to the ball to "bat it up" • How long until you lose 10 balls? /1
7
54
242
@s_gruppetta_ct
Stephen Gruppetta
2 years
In what situations is NumPy faster than vanilla Python? Short answer: if you want to perform the same operation on each item in a sequence, it's likely NumPy will be faster Let's look at an example in which we compare using lists with append, list comprehensions, and NumPy /1
Tweet media one
7
34
232
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 4 in the Python functions series is all about: *args It's not as difficult or as weird as you may think Let's dive in and find out more Here's the example we'll start with… <code in ALT text> /1
Tweet media one
14
22
214
@s_gruppetta_ct
Stephen Gruppetta
2 years
Functions in Python—easy or hard to learn & master? This week I'll look at aspects of functions which can be tricky for those who know basics and want to move to next level Let's start with the unexciting but important—terms • define • call • parameter • argument 1/
Tweet media one
15
34
211
@s_gruppetta_ct
Stephen Gruppetta
2 years
A very common error with #Python comprehensions… You have: • list comps • dict comps • set comps • tuple comps But… 👇🪡🧵 1 of 7
Tweet media one
11
35
205
@s_gruppetta_ct
Stephen Gruppetta
2 years
Do you always use the square brackets notation to get a value out of a Python dictionary? This is often fine and convenient, but there's an alternative with a difference – the `get()` method Here's an example in the code snippet Let's go through each one… /1
Tweet media one
6
26
203
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 6: Special Methods (aka Dunder Methods) --- It's Year 6. Students will dive deeper into what's happening inside classes. This Year focusses on special methods Here are our classes so far 1/
Tweet media one
6
41
198
@s_gruppetta_ct
Stephen Gruppetta
2 years
An image is made up of pixels. Sure… But let's look at a different set of building blocks which make up an image Claim: An image, like the one on the left, can be made up of building blocks that look like the wave-y pattern on the right Read on to be convinced… /1
Tweet media one
Tweet media two
6
53
196
@s_gruppetta_ct
Stephen Gruppetta
2 years
Yesterday, I talked about the `for...else` loop in Python The `else` clause can also be used with a `while` loop Let's look at a short example which uses a `while...else` loop /1
7
25
192
@s_gruppetta_ct
Stephen Gruppetta
2 years
In the early days of learning to code in Python, you learn about data types and data structures… …but you also hear lots of other terms such as • sequence • container • iterable • mutable and immutable and more terms… You _could_ learn all the definitions… 👇🪡🧵 1/
9
35
185
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 6 of the Python functions series: • more on *args & **kwargs In this thread, we'll look at functions with some combination of "normal" positional arguments, *args, and **kwargs Let's start with this example –> What do you think the output will be? <code in ALT text> /1
Tweet media one
5
26
188
@s_gruppetta_ct
Stephen Gruppetta
2 years
Why should I care whether something is mutable or immutable?" Often, beginners can see these distinctions as unimportant. But that's the difference between thinking this behaviour is an error or that it makes perfect sense — see code attached 👇🪡🧵 #python /1
Tweet media one
10
35
184
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 2 of diving into Python functions—today we'll look at: • positional arguments • named (or keyword) arguments I don't have a preference on which term to use for the latter! Here's a simple function —>Which of the five function calls will not work? <code in ALT text> 1/
Tweet media one
12
41
180
@s_gruppetta_ct
Stephen Gruppetta
2 years
You know about the `for` loop, I know. But do you? Are you sure? Let's break the `for` loop down to see what's happening just a bit underneath the surface Read on… 👇🪡🧵 #Python /1
13
34
181
@s_gruppetta_ct
Stephen Gruppetta
2 years
What Python data type would [a multi-storey car park] be? ––– You drive into a multi-storey car park, find a spot to park, and then you ask yourself: "what data structure would best represent this car park", of course Let's explore 1/
Tweet media one
9
29
183
@s_gruppetta_ct
Stephen Gruppetta
2 years
Do you know anyone who's looking to learn to code? Maybe _you_ are? Maybe you've tried in the past but gave up? You may want to give a try – it's a different type of learn-to-code book, focusing on being friendly, accessible yet still very thorough…
6
39
181
@s_gruppetta_ct
Stephen Gruppetta
2 years
`is`, `==`, and the £5 note in your pocket You've read about how `is` and `==` are not the same thing. But perhaps, you still find the concept a bit confusing. So, here we go. Read on 👇🪡🧵 #Python /1
Tweet media one
13
59
172
@s_gruppetta_ct
Stephen Gruppetta
2 years
Did you know… …you can round to the nearest thousand in Python? >>> round(3256, -3) 3000 Or to any other level of precision, of course
Tweet media one
9
20
169
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 4: More interaction between classes --- Year 3 was a busy year. Here's were we left in Year 3 /1
Tweet media one
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 3: Defining Methods --- Students are no longer fresh-faced first years, but there's still a lot to learn. Real stuff starts this Year as they learn to define methods to add functionality /1
5
9
48
6
30
168
@s_gruppetta_ct
Stephen Gruppetta
2 years
Dunder Method of the Day: __contains__() As the Athletics World Champs are running, let's look at a track & field-themed example Read on… 👇🪡🧵 1/
Tweet media one
4
37
171
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 7: Final Year (Class Methods | Static Methods) --- Students are taller than most professors now–what a change from Year 1! But there's still one Year to go before graduating from Hogwarts 1/
Tweet media one
3
33
160
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 7 in the Python functions series Have you ever seen a "rogue" forward slash / in a function signature when reading documentation? Like this one? def greet_person(person, /, repeat): Let's talk about positional-only arguments today… /1
Tweet media one
8
33
160
@s_gruppetta_ct
Stephen Gruppetta
6 months
Hello The Python Coding Book
Tweet media one
10
24
160
@s_gruppetta_ct
Stephen Gruppetta
2 years
Another feature of the `for` loop that many beginners are surprised to see is the `else` clause Let's assume you want to find the first palindrome in a list of names: names = ["James", "Anna", "Mark", "Kevin", "Kate"] 1/
9
24
157
@s_gruppetta_ct
Stephen Gruppetta
2 years
Why Light Mode is better than Dark Mode (for me) — the science Often there are discussions about dark move vs. light mode preference… I prefer light mode and I have a reason why — here's a mini experiment and a summary of the science… 👇🪡🧵 #darkmode #programming /1
Tweet media one
12
30
144
@s_gruppetta_ct
Stephen Gruppetta
1 year
Over the past 2 weeks I published a 7-day series on classes & OOP I knew I couldn't talk about everything, but I also wanted to make it reasonably (!) comprehensive Here are all the threads, from Year 1 to 7 at Hogwarts School of Codecraft and Algorithmancy It's long 0 of 7
7
37
143
@s_gruppetta_ct
Stephen Gruppetta
1 year
Object-Oriented Python at the Hogwarts School of Codecraft and Algorithmancy --- Year 1: Mindset --- Students join the school, are sorted into houses, and start learning about what's different in object-oriented programming (OOP) compared to the programming they already know 1/
11
37
148
@s_gruppetta_ct
Stephen Gruppetta
2 years
Have you used `subplot_mosaic()` in Matplotlib yet? Or are you a dinosaur like me and still used older functions? After all, `subplot_mosaic()` was only introduced in 2020 in version 3.3 Today, I decided to finally explore `subplot_mosaic()` 👇🪡🧵 @matplotlib /1
Tweet media one
6
28
141
@s_gruppetta_ct
Stephen Gruppetta
2 years
The friendly, relaxed, #Python book It's a textbook, but don't call it a textbook, it doesn't like it. And it's free, by the way. Did I mention that? Do you want to #LearnToCode ? Give it a try an tell me what you think… --- #programming
2
49
133
@s_gruppetta_ct
Stephen Gruppetta
2 years
Matplotlib has two alternatives to create plots and figures. This can be confusing for beginners… …from a beginner's perspective, it's best if there's only one way of doing things. Read on 👇🪡🧵 #python #matplotlib /1
4
20
131
@s_gruppetta_ct
Stephen Gruppetta
2 years
Let's have a quick look at the unpacking operator * in Python Let's assume you have a name with all the middle names but you only want to keep the first and last names: 👇🪡🧵 1/
Tweet media one
6
18
132
@s_gruppetta_ct
Stephen Gruppetta
2 years
One of the first things you learn when learning coding in #Python is how to define functions. Then you start digging deeper, and you'll need to master how to use optional arguments in functions. Here's my @realpython article about optional arguments:
3
26
131
@s_gruppetta_ct
Stephen Gruppetta
2 years
The Data Structure Category Series is now complete with 7 days of posts plus one bonus mid-series interlude Here are all the threads linked in one place, and the visual summary, too See replies for link to each Day's thread… 1/
Tweet media one
4
28
125
@s_gruppetta_ct
Stephen Gruppetta
9 months
Do you want to learn Python in 6 weeks? If you answered yes… Sorry, I can’t help you…
17
10
122
@s_gruppetta_ct
Stephen Gruppetta
2 years
There are a few million ways to read a CSV file in Python, more or less Sometimes, the simple solution is all you need import csv with open("some_file.csv") as file: contents = csv.reader(file) for row in contents: print(row)
6
20
122
@s_gruppetta_ct
Stephen Gruppetta
2 years
Here's a question you know the answer to: "How does a Python `for` loop work?" "What a silly question", I can hear you think. But, do you _really_ know what's happening behind the scenes? Let's have a look at iterables, iterators, and the `for` loop… /1
7
28
118
@s_gruppetta_ct
Stephen Gruppetta
2 years
f-strings? fantastic-strings formidable-strings fancy-strings fabulous-strings Let's look at a number of ways we can deal with strings in Python (Spoiler alert: f-strings are the best—did you get the clues that I quite like f-strings? Or was I too subtle?!) /1
Tweet media one
10
21
116
@s_gruppetta_ct
Stephen Gruppetta
2 years
When you need to loop through items in a list and also keep track of an index, you don't need to do this 'manually'… …here's where `enumerate()` comes in useful 👇🪡🧵 1/
Tweet media one
4
26
116
@s_gruppetta_ct
Stephen Gruppetta
2 years
Here are two strings: >>> size '5µm' >>> another_size '5μm' And here's their comparison: >>> size == another_size False Why? /1
9
15
108
@s_gruppetta_ct
Stephen Gruppetta
2 years
What Python data type would [a row of houses] be? ––– Let's look at a residential street with terraced houses I'll call the "object" `row` for row of houses And let's start looking at some properties we want to check for First: can we go from one house to another in order? /1
Tweet media one
4
17
105
@s_gruppetta_ct
Stephen Gruppetta
2 years
Need to extract the first and last item from a Python string or list, say? Here's one way of doing it in a single line… >>> first, *_, last = "Stephen" >>> first 'S' >>> last 'n' >>> first, *_, last = [12, 3, 5, 13, 99, 0] >>> first 12 >>> last 0
Tweet media one
7
12
101
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 12 on Python Functions: • Docstrings Here's something that won't affect how Python treats your functions… …but will affect how other people (and your future self) will Here's the example we'll use here: <code in ALT text> 1/
Tweet media one
3
11
95
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 3 on Python Functions. Today it's the turn for: • optional arguments / default values Let's build on the same function used in Days 1 and 2. One of these options raises an error —> I bet you know which one? <Code in ALT text> /1
Tweet media one
3
12
91
@s_gruppetta_ct
Stephen Gruppetta
2 years
@RealBenjizo `True` as `sort()` sorts in place and returns `None`
3
1
92
@s_gruppetta_ct
Stephen Gruppetta
1 year
When you first start using NumPy arrays, it's easy to think they're similar to lists… …and there are similarities. But there are also differences Let's look at one difference with indexing… 1/
Tweet media one
3
12
91
@s_gruppetta_ct
Stephen Gruppetta
2 years
Time for a quick intro to new and old friends… I'm Stephen, but you know that already. On my feed you can expect: <✅> General Python <✅> NumPy & Matplotlib <✅> turtle projects (but not the boring ones) <✅> Scientific programming <✅> A dry sense of humour, at times … 1/
6
14
88
@s_gruppetta_ct
Stephen Gruppetta
2 years
Who said the `turtle` module in Python is there just to draw boring squares and circles? Here's one of the (many) Christmas-themed animations I have - I'll share more in the lead-up to Christmas…
6
14
87
@s_gruppetta_ct
Stephen Gruppetta
2 years
To finish off the series of lesser-known tools in Python loops, here's the `continue` keyword We'll look at a very simple example to demonstrate how this keyword works /1
Tweet media one
3
11
85
@s_gruppetta_ct
Stephen Gruppetta
2 years
Anyone wants a step-by-step tutorial on creating this lunar landing game using #Python 's turtle module? #coding #programming #100daysodcode #learnPython #LearnToCode
16
12
88
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 2 on NumPy indexing… Yesterday, we saw some differences between indexing lists and NumPy arrays NumPy arrays provide more options, such as using two indices within the same pair of square brackets, as we saw yesterday Let's dive a bit deeper today with more dimensions /1
Tweet media one
2
16
86
@s_gruppetta_ct
Stephen Gruppetta
2 years
What happens when you reverse a `range` object in Python? A range object is a sequence. This means it is: • An iterable • A container • A sized object (it has a length) • Indexed using an integer It also means it can be reversed as all sequences are reversible /1
Tweet media one
2
17
88
@s_gruppetta_ct
Stephen Gruppetta
2 years
A few days ago I posted a "countdown to Christmas" code. Here's the updated version… This should work before, on, and after Christmas day… See below for a brief walk through… <code in ALT text> /1
Tweet media one
3
10
87
@s_gruppetta_ct
Stephen Gruppetta
2 years
Let's talk about nothing today… …no I mean it. Let's talk about Python's `None` It's a confusing concept for beginners and it pops up in "unexpected" places, until you know to expect it there… Ok, let's add some substance to nothingness… /1
7
25
87
@s_gruppetta_ct
Stephen Gruppetta
2 years
––– Mid-Series Roundup (Day 5.5) ––– Let's review the terms we've seen so far but in a different order to how I presented them in this series Let's start with three “top-level” categories: • Iterable • Container • Sized 1/
Tweet media one
5
17
89
@s_gruppetta_ct
Stephen Gruppetta
2 years
Which of these coffees is _the same_? *Don't* read the next tweet in the thread before you've come up with an answer… /1
Tweet media one
5
16
85
@s_gruppetta_ct
Stephen Gruppetta
2 years
Sometimes, all you need is a Named Tuple Choosing the right data structure can be tricky. Should you create a class? Maybe a list or tuple? A dictionary? Or dataclass? All have their own place, but sometimes, the oft forgotten named tuple is all you need 👇🪡🧵 1/
6
15
86
@s_gruppetta_ct
Stephen Gruppetta
2 years
Slicing: A Short Story **Now Streaming** --- Season 1: Going forward Main character: a list called `numbers` with values which match the indices (easier to follow the story) But other sequences could be used for this role… Synopsis: Main character explores slicing 1/
Tweet media one
3
18
83
@s_gruppetta_ct
Stephen Gruppetta
2 years
If you've seen this you know it. If you haven't, probably you don't. There are patterns that become really easy once you know them but are not immediately obvious. Here's a common issue with lists and loops. Which #programming language, if any, will be left out? #Python
Tweet media one
16
13
78
@s_gruppetta_ct
Stephen Gruppetta
1 year
Let's look at a special method that's reasonably well-known, and its cousin that may be less well-known Let's start with `__add__()` and let's look at how it works in this demo example of an `Article` class /1
Tweet media one
3
15
84
@s_gruppetta_ct
Stephen Gruppetta
7 months
@svpino Or: np.max, np.min = np.min, np.max
5
0
82
@s_gruppetta_ct
Stephen Gruppetta
4 months
@PhysInHistory Is “the scientific method” a valid answer?
7
1
84
@s_gruppetta_ct
Stephen Gruppetta
8 months
This remains one of the most fascinating lines in Python, in my view What's the output? Once you have an thought of an answer, read the rest of this thread /1
Tweet media one
10
17
83
@s_gruppetta_ct
Stephen Gruppetta
2 years
Is there a Python module to cure headaches?
32
4
79
@s_gruppetta_ct
Stephen Gruppetta
11 months
Another f-string format specifier I had never used until researching my latest article was the 'n' type. I had to virtually travel to another country, though, to see it in action:
Tweet media one
6
14
78
@s_gruppetta_ct
Stephen Gruppetta
2 years
When beginners think they know everything there is to know about the `for` loop, here comes looping through dictionaries. It can take a bit of re-learning to master looping through dictionaries. Let's look at an example… 1/
3
11
77
@s_gruppetta_ct
Stephen Gruppetta
2 years
If you're looking for a fun yet challenging project to play with NumPy 2D arrays and images and, yes, the best topic maths has to offer… …here's this evergreen tutorial – consistently the most-popular of the articles on the The Python Coding Book blog:
1
17
81
@s_gruppetta_ct
Stephen Gruppetta
2 years
Do you often find yourself importing math to use math.sqrt(number)? Save yourself an import and just go for number ** 0.5 It might even be a bit faster in some situations (and to some, yes, less readable) #python #math #maths #coding #codenewbie
6
13
73
@s_gruppetta_ct
Stephen Gruppetta
2 years
map() and filter() are cool and useful functions in #Python , but often you can use list comprehensions instead… #listcomp #coding #codenewbie
6
7
76
@s_gruppetta_ct
Stephen Gruppetta
2 years
A thread on Python names, objects and reference counts If you're an intermediate-ish Python learner, you've probably ignored this stuff until now. But maybe, you're starting to get a bit curious. Let's explore a bit 👇🪡🧵 1/
Tweet media one
4
18
75
@s_gruppetta_ct
Stephen Gruppetta
2 years
It's close enough to justify this
Tweet media one
2
11
72
@s_gruppetta_ct
Stephen Gruppetta
2 years
One of my "Aha!" moments when learning Python was when I realised I could do this! #Python #programming #coding
Tweet media one
7
9
72
@s_gruppetta_ct
Stephen Gruppetta
2 years
Here's something you'll never, ever need to know about Python… >>> bool(...) True Ellipsis is truthy. Now you know…
10
3
72
@s_gruppetta_ct
Stephen Gruppetta
2 years
More Animated Christmas Cards using Python's `turtle` module Earlier this week, I posted a particularly complex animation Today, a slightly simpler one, although there's still al lot happening in the code…
3
9
73
@s_gruppetta_ct
Stephen Gruppetta
1 year
Understanding how colour images are represented is easier with small arrays Here's a 10 x 10 x 3 array. Picture a 2D array with 10 rows and 10 columns (that's 100 pixels) Now take three of those 10 x 10 arrays and stack them on each other /1
Tweet media one
Tweet media two
4
16
72
@s_gruppetta_ct
Stephen Gruppetta
2 years
––– Day 1 ––– ––– Iterable ––– Let’s start with iterable Easy 'definition' first: Any data type which can be used in a `for` loop /1
4
14
73
@s_gruppetta_ct
Stephen Gruppetta
1 year
In today's final session of 'The Python Coding Programme', the discussion led us to imagine what "append" would look like from a functional programming perspective, so we wrote this… What other options do we have? Aim was to use immutable types, hence never change object
Tweet media one
4
11
69
@s_gruppetta_ct
Stephen Gruppetta
9 months
One last step-by-step `turtle` animation for the year. Let's build this Spinning Globe Dots animation (surely, there's a better name for it) I'll do this in an old-fashioned thread which works better for a step-by-step approach, I think. Here's the animation… 1/
6
17
70
@s_gruppetta_ct
Stephen Gruppetta
2 years
The difference between shallow and deep copy in Python… …in pictures Read the thread for captions to the pictures! 👇🪡🧵 1/
Tweet media one
Tweet media two
Tweet media three
4
10
69
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 13 – Final Day – of the Intermediate Python Series We'll keep this very short and sweet – a couple of best practices when writing functions 1. Start the function name with a verb 2. Write functions that only do one thing 1/
2
9
65
@s_gruppetta_ct
Stephen Gruppetta
2 years
A common pitfall early on in the Python learning journey This does _not_ create a copy of the list `numbers` Let's see what it does and what to do to create a copy /1
Tweet media one
3
13
67
@s_gruppetta_ct
Stephen Gruppetta
2 years
Why is Python the ideal language for beginners to learn? Let's look at the main reasons: • It's more accessible for a beginner, allowing you to focus on programming concepts and not language detail. Too many give up coding early on–Python makes this less likely cont/d… /1
1
15
66
@s_gruppetta_ct
Stephen Gruppetta
2 years
Day 10 of the Python Functions Series. Let's talk about type hinting today, or just "typing" I'll use an example I've used earlier in the series but add type hints to it —> Will both of these function calls work or will any raise an error? <code in ALT text> /1
Tweet media one
4
8
58
@s_gruppetta_ct
Stephen Gruppetta
2 years
How to get cat in image 1 onto courtyard floor 2? Using #Python 's #Pillow library of course There are other ways—I know—but none are as fun as using some fundamental #ImageProcessing I discuss this + more in my latest @realpython article: #100daysofcode
Tweet media one
8
23
62