"That's a Forever Job": Weekend Python in Surrey
"That's a Forever Job": Weekend Python in Surrey
I know, I know. I have stopped working weekends, and I don't ever do work work and for the most part I have stopped studying. BUT I AM IN A PLACE RIGHT NOW WITH MY PYTHON COURSE WHERE IT'S LIKE A STORY AND IT'S LIKE A BOOK AND I CAN'T PUT IT DOWN. I can't wait to find out what happens next with iterators!! I just can't wait, I just can't wait to find out!!! I am on a cheeky weekend trip to Guildford, in Surrey. I don't know why. I wanted to go to my favourite Bubble Tea place.
Which they also have in Brighton - but I wanted more exciting - but London was a little bit too far and so I wanted to make a fancy trip out of it. One of my colleagues lives where I'm going so I can tell him.
Infinite Iterators
"An infinite iterator will repeat an infinite number of times with no endpoint and no StopIteration exception raised. Infinite iterators are useful when we have unbounded streams of data to process." NONE OF THIS MAKES ANY SENSE TO ME!!! I wrote up lots of notes on the itertools count method in my notebook and it all makes sense to me so I'm going to continue.
OH SO HELP ME GOD
I wrote some code that I don't really get so here goes.
import itertools
max_capacity = 1000
num_bags = 0
for i in itertools.count(start=13.5,step=13.5):
if i >= max_capacity:
break
num_bags += 1
print(num_bags)
Okay so I'd like to break it down like I did back in the day with those Codewars problems.
WOW. I really miss those times. Wow.
So. There:
- We import itertools because we need it to use the count method
- We set a value called max_capacity which is the maximum capacity of our shelving unit for our flour. Every bag of flour weighs 13.5 lbs.
- We make i the total value of the count method at every iteration.
- We start off at 13.5 because in the first iteration of the loop nothing gets added - we just start at the start weight and increment the counter by one. This one really threw me and I spent ages analysing it with Chat GPT. But on the first loop we don't increment; we just increase the counter by one.
- We keep going through the loop until we reach the max capacity, at which point we break out of the loop.
I don't really like this. It's very finicky. It feels like learning JavaScript all over again.
Input-Dependent Iterator: Chain
(continuing in a super cool art coffee shop called Art & Grind - just off the high street).
"An input-dependent iterator will terminate based on the length of one or more input values.
They are great for working with and modifying existing iterators."
"A useful tool that is an input-dependent iterator is the chain() tool. chain() takes in one more iterables and COMBINES THEM INTO A SINGLE ITERATOR". WAIT WOW WOW WHAT'S THIS? WHAT'S THIS? WOW.
chain(*iterables)
This is the syntax. "The input of chain() is one or more iterables of the same or varying iterable types. [...] The output is finite since the input iterables are also finite." I did all the code listed out in this exercise.
for loops are definitely becoming muscle memory.
Combinatoric Iterator: Combinations
I'm still in the cafe in Surrey - haven't missed working on the weekends - and might not repeat this.
But it feels good to be making some progress. In future I might stick to train journeys to London if I feel I want to and to working hours.
"A combinatric iterator will perform a set of statistical or mathematical operations on an input iterable."
"A useful itertool that is a combinatric iterator is is the combinations() itertool. This itertool will produce an iterator of tuples that contain combinations of all the elements in the input. combinations(iterable, r) this is the syntax. "The combinations itertool takes two inputs, the first is an iterable, the second is a value r that represents the length of each combination tuple." ... .... ...
I understand NOTHING.
But I know that I value renewable energy, and I know that I have to keep on going.
And I love the water tech too.
I wrote some further code.
And more importantly - and I want to tell this to my boss - I am seeing a really huge huge fluency in terms of my Python coding typing - IT IS REALLY BECOMING MUSCLE MEMORY! WOW, WOW, WOW, WOW, WOW!!!! I am so pleased. I finished off the whole of the lessons and I finished off all of the quiz as well. OMG YES I GOT 100% FINALLY. I HAVE BEEN TRYING SO HARD TO GET 100% FOR SO LONG.
There was one thing I didn't get - might ask. Thank you. See below please.
"That's a Forever Job"
I had to change at Gatwick Airport this morning. I nearly cried. I hadn't been there since I was visiting my then boyfriend at 21 in London.
I remembered; I had dropped out of University. I had no hope or prospects. I had no idea what I was going to do next. I didn't trust the whole process but I should've trusted. I got 3 degrees. I have been working for 3.5 years now. And I am doing really well. Trust me - I am doing really well. On my second platform I got a coffee from two nice men.
One of them asked me what I did. I told him I was a software engineer. He said "that's a forever job!".
Yes, my friend. Yes.
Comments
Post a Comment