‘Common sense rather than KPIs.’ Interview with VP of Human Resources Natalia Chisler

In the eight years Natalia Chisler has been with JetBrains, the number of staff has exploded from 120 to over 800 working across 6 distributed offices. JetBrains software is used by millions of developers worldwide, and many of them dream of joining a JetBrains team to help improve the professional tools for themselves and their peers. So what does it take to become a part of JetBrains? Do you even stand a chance if you’re not a Senior Developer? Read our interview with Natalia for answers to these and other questions.

Natalia Chisler, VP of Human Resources

Photo by Alexander Nefedov

Today, all new hires go through the HR department before they join JetBrains. How did it work when you applied, and what is your background?

Well, most people around me are involved in programming in one way or another, including my parents, husband, son, and many of my friends. I went to the Physics and Mathematics Lyceum 239 in St. Petersburg, where I realized that even though I would not specialize in math or computer science, my life would still continue to revolve around people who do.

I liked working with people so I studied Human Resources at university. These two things, HR plus IT, turned out to be a good combination. Back in the early 2000s, the IT recruiting scene in Russia was just coming into its developing stages, so I was lucky to have been a part of really challenging large-scale projects for IT companies.

7 years later, I was invited to join the HR department of a British IT company. That’s where I met Andrey Ivanov, who later introduced me to JetBrains. That’s how this chapter ended… and then my story really began.

Continue reading

Posted in Interview | Tagged , , , , , , | Leave a comment

Developing the basics: Programming myself, post fifteen

treasureMap_15

<< Read the previous post from this series

The Journey of One Thousand Lines of Code.

So that about wraps it up then. It has been quite an adventure discovering the world of computer programming and learning a new skill which I can take on into the future. I am sure that there are parts I could have done better and more efficiently, and I have a whole new respect for dedicated learners who are trying to change their paths in life by learning new skills outside their comfort zone. It is hard, it takes incredible discipline (which has been one of the biggest problems I have had) to dedicate your free time every day to the pursuit of something that will pay off for years to come.

It’s a trap

There are a lot of things to distract you from the goal of learning any new skill. The thing you have to remember is everything is a choice and a decision. If you decide to go on Facebook the whole night, then this is your choice. How you spend your time is your choice, there are some decisions you can make which can have a much better pay off than others and this is what you need to keep in mind. If you are going to do this, it is up to you. Distractions are going to come up, it is how you deal with them that will be the difference between success and failure.

There are a lot of things in life which will get in your way and unfortunately, if you are not dedicated enough, it is very easy to dismiss the practice of a new skill. This goes for everything, coding, learning to play a sport, learning an instrument, even getting better at your job, you can passively go through and you will get experience and learn enough to do a satisfactory job, and after years this experience may even help you to be quite good. But this is the difference between someone who can and someone that does, dedicated practice and learning will put you far beyond the average person doing the same thing as you in your field. With the information that is available to anyone with an Internet connection, there really is very little that can hold you back in your pursuit of knowledge, and the best part, so much of it is available for free.

These tips should help you stay on track:

Make sure it becomes a habit to learn – set aside the hours in the day where you will pursue your goal.

Make sure you have a strong motivation –  From the outset, write down why you are doing this, what it is all for and the impact it will have on your life once you master the skill you are pursuing. Use it as a mantra if you are feeling ‘hmm not today’ so you can reaffirm what this is all for

Make sure everything is on hand – finding yourself just getting a drink, getting a snack, generally procrastinating? Just make sure it is all at hand so you don’t have any excuses not to get started and especially not to stop once you have started.

Make sure you are persistent – even if you can’t do a lot that day, do something, anything toward the goal. If you are having a bad day still try to do something. Being persistent is the secret weapon.

Make sure you get some variety – different learning media keep it all interesting. When it is interesting it is easier to get excited about doing the activity. Also, it can provide new ways to understand and think about it all.

Make sure you are pushing yourself – the harder you work at something the better you will get. Don’t just settle for “kind of knowing”, or giving up on a feature in your project because it seemed too hard, work on it and amaze yourself with what you can do.

 

How did I do?

Dreyfus model of skill acquisition

There is a popular model for skill acquisition known as the Dreyfus model, which proposes that there are 5 levels to mastery of a skill.

Novice: at this level, you are completely new to the skill and can read about exercises and follow step by step through putting something together. You are not thinking for yourself, really, and without some kind of assistance, you cannot achieve anything outside of the specific exercise. You maybe know some jargon and how the basics work, but you are probably not aware of how they really function in the big scheme of things. In terms of coding, a novice would be able to look at the code and step through what it is doing on a basic level.

Advanced Beginner: advanced beginners have experience in real situations, so they are starting to know how the basics work together to provide a result. So in terms of coding, they would be able to look at the code and understand what is going on there, but more importantly what they can change and improve. If this was, say, a musical instrument, an advanced beginner could probably read a new piece of music and play it and add some little riffs. So at this level, you can do some specific programs and kind of know them by heart.

Competent: this is the stage where you know the code and the different parts of it enough that you can begin to approach new tasks from scratch. You know how it all works together and can break down a problem into its constituents, work out what needs to be done, and work out any gaps you have for knowing how to do something.

Proficient: well, now there are no gaps, you know pretty much everything you need to do something without having to look it up or ask someone. This is a cool level to get to, and you are going to be recognized as knowing your sh… stuff as you know exactly what you are doing.

Expert: You recognize how you can get something done and don’t have to follow any of the normal rules, because you understand enough to know when to break the rules. The only example most people might be able to relate to is the ability to use your own native language. You can probably come up with a word to describe something which perfectly encapsulates it, this is the level of mastery that this level proposes… “The truth is there is no spoon” level mastery.

 

Skill Level/ Mental Function Novice Advanced Beginner Competent Proficient Expert
Recollection Non-Situational Situational Situational Situational Situational
Recognition Decomposed Decomposed Holistic Holistic Holistic
Decision Analytical Analytical Analytical Intuitive Intuitive
Awareness Monitoring Monitoring Monitoring Monitoring Absorbed

 

How this looks for me

So now I have some hindsight on the different learning I have taken and can look at it kind of objectively, it is possible to see where some of the resources fit in with the skill acquisition. So first and foremost, let’s start with the resources that are limited to Novice.

Novice – In terms of what only really provides scope within the novice level, I would have to place the Introduction to Python course on Stepik using PyCharm Edu. It is useful to get started with the language and see how it is used and so for this purpose it is perfect, but you will not probably get the practice you need to progress further through to the higher skill levels.

Advanced beginner – Most courses fit into this level. I would put the Head First books here as they will take you through the basics and you will begin exploring and experimenting with some of the features of the language, it will give you a sharp set of situational tools, but the scope of the books does not take you much further in terms of your own project. But that is not to say that the things learned in the books could not be directly applied to the projects you take on.

CS50 is on the top border of this. The lessons cover the novice skill level, but the problem sets put you right at the top of the advanced beginner level. It has the potential too to go through to the competent level if you use the understanding from the course to build a big final project. I would say this course will easily leave you at the top end of the Advanced Beginner level if not further.

Competent – Of all the courses, the one which has the biggest potential to push past the advanced beginner level is the advanced Python course from Stepik and PyCharm Edu. It has plenty of exercises and practice covering a wide variety of different situations and with a lot of elements having to recognize the problem in front of you and come up with a solution to it yourself. I think that after going through this, you will have a proven skill set and enough competency and experience of problem-solving to work on any problem put in front of you. Most of these exercises you have to work through without guidance, and for someone who has not had programming experience before they are definitely challenging and will put you to the test. It makes you recall the lessons learned up to this point to complete them. This means you are getting more practice in recognizing situations and how you can go about solving them and recognizing more patterns in how they are solved too. When you have this mastered, you will be at a competent level.

Proficient and Expert can only really be achieved with projects. Projects are what will push the boundaries past the simple foundations to actually something you could start a career in. The only way to get project experience would be to do tasks and projects for yourself, for example as personal projects or through your work. The more you do and the more diverse the projects, the closer you are going to get to be an expert in the craft you are developing.

 

How to acquire the skill levels

The way to learn anything, I still think, is to follow a specific series of steps that will be the same for basics and advancing in skill on both the micro and macro scale.

Step 1: Foundations. The first step is actually to learn the basics and the theory about something, so the foundations. This can be done with a book or video or teacher in a classroom. Basically, it is to get to know the fundamentals of how things work; the material I used in the novice section was perfectly suited to this point in the learning cycle.

Step 2: Practice. Use the theory you have learned and put it into practice. By looking through the theory and then applying it to real situations, you deepen the understanding of the concept. This is why the CS50 course is so well adapted. But you really have to take the time to actually go through the problem sets. This is one of the biggest things I would have done differently as I ducked out of the problems sets on most occasions as I couldn’t find the time to get through them making the course probably only about 30% as effective as it could have been. The Stepik Adaptive Python course is another chance to get some good practice in though.

Step 3: Personal projects. To really get skilled, you are going to have to push yourself outside of your comfort zone and the best way of doing this is to take on a project you are interested in. This would be the next step for me if I am going to continue to improve my coding. The best part about it being a personal project is that it can really be about anything you want, you can impose whatever limit you want and just work on making it happen. This is also a great way to fill in skill gaps, as you will likely come across hurdles which require a little work to get over and have to learn about new things to get the project working properly. Also, the benefit of starting a personal project is that you will probably find yourself reaching out and asking for help from more experienced people in the community. This kind of knowledge sharing goes both ways and will give you an outlet to talk about your ideas and discuss and understand things from other people’s experience.

Step 4: Go professional. If you want to be a master of a craft, then you are going to have to spend a lot of time doing it. If you take the 10,000-hour rule as an approximation to mastering a skill, this basically equates to 5 years if you work on the skill 9 to 5 every day. The final way then to become the best at the skill you wish to master is to take an internship or even a job. Performing the skill on a daily basis and being responsible for it will push you to really become very good at it. This is what separates the hobbyists (not hobbits) from the professionals: when your income depends on being good, then you start to become very good very quickly.

 

What I might have done differently

In terms of the learning materials, I really can’t complain about any of them. There is a reason that people recommend them. I wish I had got to go through the [Learning Python course on Coursera] but I think I have a good foundation now to build on. Time is the biggest issue here, as is the dedication to learning; I think if you really dedicated yourself to this process and didn’t have any distractions like kids being born… busy times at work and a normal life… you could get through everything in about 16 weeks and you would be at a decent level. The hardest part is that all these courses are possible to put down and come back to. The CS50 course has some time pressure put on it, and I think if you tried to keep up with the course in real time, week for week, it would be a good way of getting through the course. Constant work on this really is the only way to properly learn it; I have had weeks off and come back to things after a while and had to approach the Advanced Python after some time out only to find myself completely stuck with the questions. It was only after looking into it a bit that I found the task to be something I had learned an approach to months before, but because of the gap, it was absolutely irretrievable from my memory.

So in terms of how I approached the project, I think the courses were taken in the best order. Even though it was not totally planned this way, it turned out the most logical order for them, taking me from novice to advanced beginner, I still have some work to do before I am really competent and proficient is a distant goal… Expert, I think, would take 5 years or so. So in 6 months to get to a level that I can play about with the code a bit is OK. I have the basis to make a minimum viable product using other people’s tools to build on, so this a totally acceptable level for me to get to in half a year. Though I think it would have been possible to get much further with this with a little bit more work, discipline and commitment.

 

“What next?” I hear you ask

Well, the process is not finished, not by a long shot. I particularly liked the Head First books so I am going to look at some further technologies with this series. I still have a lot of exercises to get through with the Adaptive Python, and once I have got through it I will go through it again. It is good practice to try and get through these kinds of exercises, especially since I have never had to do anything like this from scratch, and the more I do it the better I get. The goal would be to be able to do the exercises under the time limits they recommend as possible which is usually about 5 minutes. So to get there you need to know your sh… stuff. Otherwise, I will start on some of my own projects, there are a few ideas for things which I think would be fun to create. This is the joy of programming – you can literally create whatever you want… Maybe an AI which will sit down and teach you how to program… hmm.

 

 

Everything will be okay in the end. If it is not okay then it is not the end. – The guy from best exotic marigold hotel.

Posted in Education | Tagged , | Leave a comment

Interview with Sergey Coox, the .NET Department Lead at JetBrains

Anastasia Kazakova, our Product Marketing Manager for C++ tools, talks with Sergey Coox about controlled chaos, internal competition, and keeping 90 colleagues happy at work.

Q: Hi Sergey! You lead the .NET Department at JetBrains. How big is your department and what products does it work on?

According to the latest ‘census,’ we’re 90-strong. We work on ReSharper – our Visual Studio extension for .NET, the second oldest JetBrains tool after IntelliJ IDEA; Rider – an up-and-coming cross-platform .NET IDE; a family of profilers including dotTrace and dotMemory; dotCover for analyzing code coverage; dotPeek – a decompiler for .NET apps; and finally, ReSharper C++ – a Visual Studio extension for coding in C++. That’s about it.
Coox-550
Q: Sounds like a lot! As the Department Lead, what does your job entail?

Making sure that everything works! There are many different people who need to talk with each other and reach a common understanding. That’s what I help them do. Of course, the ideal situation is when the whole system manages itself.
Continue reading

Posted in Interview | Tagged | Leave a comment

Baking Boards or the Secret Ingredient of Agile Cuisine

Behind every JetBrains product, there are numerous teams: developers, product marketing (PMM), technical writers, designers and many others. Each team has established their own workflows to match their goals, working habits, and the team profile. In an earlier post, we described how the YouTrack team had been cooking Scrum and had managed to transform this methodology to find the most balanced approach that works for them.

Today, we will tell you how other JetBrains teams organize their processes, customize their Agile boards to meet the team’s needs, and what strategies can be useful to become a real chef at the Agile kitchen.

Design Team

designTeam2

The JetBrains Design team creates all kinds of visual content for each of the 23 company products: their designs enhance our web pages, marketing materials, and printed matter.
The designers receive most of their assignments from the product marketing managers (PMMs) who often need them ready as soon as yesterday. Such a fast-paced process requires effective monitoring of new tasks and balanced distribution of them within the team.

Continue reading

Posted in BehindTheScenes | Tagged , , , , , | 2 Comments

Being Agile in Your Own Way: A Scrum Guide by the YouTrack Team

Six years ago, the YouTrack team started developing an Agile board in YouTrack (our issue tracker and agile project management tool). At JetBrains, dogfooding is one of the key principles of product development. So while building a tool for our customers that conformed to the main principles of an agile framework, we knew we had to experience Agile firsthand. That’s when we decided to adopt Scrum.

That was our first attempt towards the world of Agile practices. Unfortunately, after a couple of years (when our Agile board was released), we dropped our Scrum practices for a while. In 2016, we introduced a reincarnation of our Scrum, this time pursuing completely different goals:

  1. Switch to Continuous Delivery
  2. Speed up the development process
  3. Improve code quality
  4. Improve product vision sharing within the team

We had tried various practices, made compromises, and even had to break some of the Scrum rules before we discovered the most balanced approach that worked for us.

Unconventional Scrum Team

In a perfect Scrum world, the team is relatively small and people are collocated. That makes our Scrum team less than perfect. We’re 27 people distributed between two JetBrains offices, in St. Petersburg, Russia, and Munich, Germany.

YouTrackTeam.jpg

Being so big, we didn’t want our Scrum meetings to distract us from working on the product. That’s why we strictly limited the time we budget for our Scrum activities down to a total of 6 hours per two-week sprint. Of course, we heavily rely on video conferencing and make use of real-time team collaboration tools like Slack.

Scrum Roles

To launch our Scrum transformation, we had to define who would take on each of the core Scrum roles.

Product Owner

Product Owner.jpg

In YouTrack, the Product Owner role is taken by the Team Lead who is responsible for developing and sharing the product vision with the team. The Team Lead is the person with the ‘big picture’ in his head and the one to ensure that our product goals meet the needs of our customers, while the team searches for the best technical solutions to achieve these goals.

Scrum Master

ScrumMaster.jpgThe whole process is driven by the Scrum Master, a developer from the YouTrack team who is in charge of presenting user stories during planning, breaking them down into separate tasks, and tracking their implementation during sprints. The Scrum Master continuously monitors the progress and makes sure everyone follows the rules we agreed on. However, the real magic that our Scrum Master does is keeping the balance between the new features we are passionate about and the mundane things that we need to maintain and polish continuously. It’s like rope-walking in front of a cheering crowd.

Product Backlog

In our case, the product backlog is a set of features that we plan to implement in YouTrack. At least once a year, the team get together for a comprehensive planning session where we discuss our major goals and product vision. As a result, we create a list of the main directions to focus on and define their priorities. We also determine the minimum set of functionality we need to develop to share it with our customers as an early preview so that we can get feedback as soon as possible and tweak new features on the fly.

Backlog

Based on this list, we create a set of issues in our product backlog. We keep our backlog in a separate project in YouTrack, which is visible only to JetBrains colleagues. We link our user stories from the backlog to the feature requests and bugs reported in our public project. We also synchronize the status of each public feature request based on the appropriate status of our user stories in the backlog. This way, we keep our process transparent to our customers. We continuously fine-tune our backlog, reordering user stories as they become more or less critical. This way we try to keep the balance between our product development strategy, fresh ideas, and the never-ending but essential maintenance process.

Sprint Backlog

Before the beginning of a new sprint, our Scrum Master and Product Owner review the top items in our product backlog and choose user stories for the sprint backlog. Our sprint backlog doesn’t always have to include the top user stories from the product backlog: the Scrum Master is mindful of balancing the new shiny features, improvements to existing functionality, and maintenance.

#NoEstimates Approach

Having followed the Scrum principles for a while, we have figured out the natural pace for our team and now have a good feel for the number of user stories we can complete in one sprint. Therefore, about two years ago, we introduced the #NoEstimates approach to our Scrum process. The main concept behind this approach is that our sprint goal is to deliver a set of user stories from the sprint backlog, regardless of how many tasks we need to tackle to achieve this goal. We track our sprint progress based on the number of user stories completed. Here is an example of our sprint Burndown chart:

Burndown

This approach allows us to spend less time estimating user stories and calculating the burndown. We’ve also added a simple rule that helps us benefit from this approach: No task may take longer than three days to complete. If it does, it must be split into smaller units of work.

Scrum Sprint Planning

Every two-week sprint starts with a planning session. We get the whole team together, including QA Engineers, UX Designers, Support Engineers, Technical Writers, and Marketing Managers, to discuss the user stories that we want to tackle in the upcoming sprint.

Questions

The planning session takes typically from 60 to 90 minutes. The Scrum Master introduces each user story chosen for the sprint, and the discussion begins. Our planning session is divided into two parts: general and technical. The general part is devoted to discussing the business scope and requires the presence of all the team members.
Next, in the technical part, the developers discuss technical details and split the user stories into tasks. This part is obligatory only for developers and QA engineers. We firmly believe that these regular sessions help the whole team stay on the same page and focus on what’s important to everyone.

Scrum Sprint

When the planning session is over, the Scrum Master adds the planned user stories from the backlog to the sprint board and creates the appropriate tasks for each story. Everyone is free to take an open task from the uppermost swimlane if possible and start working on it.

Scrum Board YouTrack

  • At the top of the board, we add critical bugs and tasks we consider important to accomplish during the sprint. This swimlane helps us keep an eye on important activities that are not related to any user stories.
  • We have two swimlanes dedicated to customer support activities for every sprint. Critical problems are added to the uppermost swimlane, while common and major support issues go to the support swimlane at the bottom of the board. If we don’t resolve these issues during the current sprint, we move them to the top swimlane in the next sprint.

Scrum Sprint Demo

One of the major Scrum principles is the idea of transparency. All team members involved should be aware of what everyone else is working on, progress being made, and what the team is trying to accomplish. Sprint Demo and Sprint Retrospective are excellent tools for that.

DemoMax.jpg

The Sprint Demo, held at the end of every sprint, is one of the most exciting Scrum activities for our team, as every presenter enjoys their moment in the spotlight supported by the teammates. During the demo, the author of a user story demonstrates various usage scenarios on a large shared screen and explains how the new functionality works. Discussion and feedback are encouraged. In the end, the presenter receives a hero’s welcome and joins the audience to give the floor to the next author.

BravoMax.jpg

The Sprint Retrospective takes place after the Sprint Demo, normally on Friday. This one-hour session helps us get feedback about the completed Sprint and collect ideas for the ‘small cool feature’ for the next sprint.

Votes.jpg

By collecting, prioritizing, and discussing feedback from each member of the team, we continue with activities that have a positive impact and eliminate negative behaviors.

Votingprocess

We also vote for the new features suggested and define the winner. We discuss this suggestion, and if we find it useful, we schedule it for one of the upcoming sprint.

The Bottom Line

All in all, adopting Scrum has helped us increase our team’s performance. The team is always delivering a functional part of the product at the end of one Scrum iteration, and everybody gets in the habit of finishing things up. This feeling of achievement keeps everybody motivated. It’s easier to estimate the effort needed for the tasks, and the whole team can address issues immediately whenever they arise.

What we have achieved with Scrum:

  • We’ve decreased the number of critical bugs form 792 in 2015 to 123 in 2017.
  • Shorter release cycles: we rolled out 4 major releases in 2017.
  • Team members have a better understanding of the current product state and are more engaged in the overall product development.

Tips and Tricks

We’ve been following several principles to find our own secret ingredient in the variety of the Agile cuisine:

  • We set the rules and agree to follow them.
  • Each team member owns their work and feels responsible for creating a great product.
  • Self-management is an essential part of our process.
  • Processes require continuous tuning, as there is no endpoint on this path.
  • Tools should be customizable enough to fit your process, not the other way around.

For us, Scrum has become a foundation rather than a big strict plan that we have to follow. We’ve found that that experimenting with workflows, finding out how to combine different strategies to progress more efficiently, and continuously working on new setups are all keys to improving our daily work life and being agile in our own way.
To get a fuller picture of our Scrum transformation, read this series of related posts on the YouTrack blog.

Posted in BehindTheScenes | Tagged , , , , , , , | 1 Comment

Developing the basics: Programming myself, post fourteen

treasureMap_14

Adaptive Python

<< Read the previous post from the series    Read the next post in this series>>

Now comes the really fun part, putting all the things that have been learned over the past 5 months into practice. It should be a nice final finish to the process of learning how to program as we can see what we know and test out what we have learned, but also see where there are still gaps in our knowledge which we can work on in the future. My final challenge then is to take the Adaptive Python Course which runs with PyCharm Edu and the online learning platform Stepik and finish up my quest on learning to program to the level I set out to achieve. The platform has a few different courses available for different programming languages like Kotlin and Java, but we are getting right back to what we came here for, Python.

So the first question I guess you have is:

“What is Adaptive Python”?

This course basically doesn’t have a set way of getting through it. You progress through the exercises depending on how you did with the previous exercises. The main idea behind this is that you are challenged, not to the point where you give up in frustration and throw your computer out of the window, but just enough to keep you interested at your own personal level. This is great, as normally exercises can be kind of boring in a static format as they have to assume your level of understanding already and so take you through things that maybe don’t interest you enough as they cannot change (adapt) to your level, so it offers you a way to progress at you own bespoke pace. Stepik description. The course itself uses coding practice which includes some theory you get tasks and hints, and you just have to go through and put something together which works for the problem at hand… 428 times…
So first things first, you need to log into Stepik and enroll for the course.
https://stepik.org/ adaptive python enrollment

stepik adaptive python

 


 

 

Do it in PyCharm Edu

Actually, I don’t really want to do this course on the Stepik platform itself but in the PyCharm Edu, so easy enough open up the PyCharm Edu, File… Browse courses Adaptive Python – Join.

adaptive Python in the Edu

Don’t get scared now

I immediately regret this decision, and the cold realization hits me that this is going to be harder than just following through examples in a book. “You need to generate all possible k-combinations of n elements” for the first question.

As we talked about the other week the problem solving is now starting to kick in, it is uncomfortable, it is frustrating, and because of this it is worth doing and will obviously (hopefully) pay off. This really is something though that needs to be done to break away from the plateau of passive learning if you feel you are not really gaining enough to be able to consider yourself able to program.

This really is completely different from all the courses I have completed so far as it is total problem solving from scratch. There are no hints to begin with, and it is really crippling to realize how even though I think I have a good grasp of Python and the theory of computer science, this is the actual practice that is needed, and that there is still a lot to learn.

I guess the best place to start is declaring the variables k and n and their relation to one another… 0 < k < n.
We need to use input to input the numbers, and we need to somehow consider all the sequences of numbers up to n…

We need to print out as many lines as the variable k. So I guess then a “for loop” will be needed in there somewhere.

So as with any problem lets pseudocode it and see what we are missing. Or actually, because of the awesomeness of this course and because this question is actually really difficult for me to work out, let’s just say that one is too hard and skip it — don’t judge me!

 

Next question:

Write a function that takes a positive three-digit number as input and returns the sum of its digits.
The function should have a name digit_sum and take an argument n.

Sample Input:
943

Sample Output:
16

This is more my kind of question. But this is still a thinker. So first let’s create an input for the task.

Then it is always a good thing to test that actually what you have just done both works and doesn’t give you back something silly.

RUN
And boom yes I have worked out how to use a standard input, which will likely serve very useful for the whole course.

 

But still there is some thinking to do

Now for more thinking, have I ever learned a way to split up numbers… or strings?
So here goes nothing

Again print the result of splitSample, and yep this didn’t work. Now I have an array with [‘943’] in.
This is really actually more difficult than I thought, because the initial input is going to be a number that has no spaces in it, it is really difficult to split it up.

I guess the clue is in the question “The function should have a name digit_sum and take an argument n” but actually the function can be used for the calculating the digits all together. First I need to split these digits up…

Hmm… it works though it prints out an appended array for each number rather than just one single array, messy but on the right track.

This will print each of the characters out, a new line at a time. Ok but now how is it possible to use the data within to add it together…

Hmm… but it seems like you still need the other parts but this time let’s remove the print from the this because otherwise it will be included in the loop *facepalm:

Yes! Now we have the array/list [‘9’, ‘4’, ‘3’]

Next, it should be easy enough to add the list together… I say easy… possible is the word I am looking for here.

 

 

3 to 4 hours later.

 

 

hmm

 

 

3 more hours later.


 

But this doesn’t use a function digit_sum.

 

an hour later

 

Is it a solution?

So my solution is:

Run… In the words of Darth Vader NOOOOooooooooo! Wrong Solution.


Maybe one of the other ways of doing this works:

Nope.


Better?:

Nope.


How about?:

Nope.


Or?:

Nope.


And?:

Nope.


Also?:


This?:

Nope. but now at least it complains that my output is wrong, and I have 2 outputs instead of just 1…

Not the correct answer


So then the absolute final solution and winner goes to…:

YES!

winner winner chicken dinner


What have I learned from this

So the lesson learned from this is if they ask for a function, then they do not want you to also print the result to the console because they record both the result and the print(value), so to them the answer looks wrong… because you have two results and not just one. Also, my cleverness with the input is also not needed, you just need to give the variable a number, and you are off.

Conclusion.

Ok so problem number one down, bring on the next 427 others! This by far I have found to be one of the most fun ways to go about practicing the python programming skills as I have to think hard about the problems and how to solve them and when you pass the tasks it is really rewarding, the trick is to never give up, never surrender! The uncomfort you experience from having to get through a task is actually your bodies natural reaction to having to do some actual work; it is like giving your brain a workout much like working out and training any other muscle.

If the estimate is to be believed, I have 101 hours (I love the precision of this) worth of brain workout ahead of me, so in real time this is probably more like 400-500 hours (maybe a million if my math is right).

This is a great way to test yourself and to practice what you know over a range of different kinds of problems. Practice is the key to learning, and this is a good platform to enable it as you can get feedback on your answers and see whether they are right or whether you are well off.
By the end of this, you will have a fully tried and tested skill set and the confidence to take on some hard challenges. So with that said this is the last step in my journey to learning to program Python and the quest to become a developer.

What now?

Well after I have got through this course, I think I will start on an application of my own. I am by no means a professional programmer, but I think with everything said and done I have the foundations now to be able to at least approach programming and find out how to do any of the things I can’t do already. There are definitely some gaps though, for example, math and equations will probably help a lot as computer programming relies a lot on logic, the code itself is not the hardest part, but knowing what to do with the code to achieve certain things is the incredible part. I also don’t think that this is the kind of skill that you can ever stop learning in, as there is always something new to learn, and different problems to try and solve which makes it kind of exciting and that’s without adding in any of the new technologies and languages that are about.

In terms of projects I especially find myself being drawn to the internet technologies and maybe some game development. Which might mean that taking on a different language would be the way to go, for instance, javascript and Kotlin are supposed to be pretty useful in terms of browser-side programming, and C# for game development is apparently a good option. But this is future me’s problem, for now, there is still a lot more I can do with Python.

 

All fixed set patterns are incapable of adaptability or pliability. The truth is outside of all fixed patterns. – Bruce Lee

Posted in Education | Tagged , | Leave a comment

Developing the basics: programming myself, post thirteen

treasureMap_13

Problem-solving strategies

<< Read the previous post from the series     Read the next post in the series >>

So we are really now starting to embark on a whole new discipline that comes with programming. Logic and problem-solving. We now have enough of how and what we can do with with the code behind us that we can work out how to use the code, what different things do in the code, or if we don’t know them off by heart yet, we at least know how to look up answers and adapt and improve the results. But it is time to really stand on our own two feet and work through problems from scratch and solve them for ourselves.

The adaptive Python PyCharm Edu course from Stepik promises this. It’s a system to practice our coding and problem-solving abilities in an environment that is a bit more forgiving as we can get hints from the course. But to prepare for this next stage, let’s have a look at some problem- solving strategies and techniques that may come in useful.

Problem-solving can only be improved by you guessed it… problem-solving. If you struggle to solve problems, you are not alone. Anytime you come up against some intellectual task that can cause you a feeling of pain; this is your body’s response to really activating your brain. It hurts, it is frustrating, it makes your blood pressure rise, why even bother then, why not just bathe our brains in a nice relaxing bath of BuzzFeed articles? It is time to exercise your brain! Let’s start with a light warm-up.

Without a calculator work out the answer to 27 x 13.

So there is no set way of solving this: for me, I would break it into parts; first work out 25 x 10, then add 75 to that then add a final 26. Basically, 25 x 13 + 26 as I find 25 a much easier number to deal with. An alternative would be to times 27 by 10 to get 270, then times 27 by 3 and add the two lots together. You could also do it with the long multiplication you learned at school. 3 x 7 carry the 20, 3 x 20 + (the 20 from before), then the second row, add a 0 for the digits as we are dealing with 10’s now, 1 x 7 then 1 x 200, giving you two rows 81 and 270, then you just need to add them together and boom, same answer.

long multiplication example

By working this out, notice how you are feeling, there is probably a certain amount of physical discomfort. This is because you are activating your system 2, a concept covered in Thinking, Fast and Slow, by Daniel Kahneman. You have two systems of thinking: system 1 and system 2. System 1 is the fast system; it’s pretty much automatic and doesn’t require too much effort, for example when you solve 2 + 2 — a different kind of effort than the calculation above. System 1 will try to kick in first, as it takes the least effort and so your brain prefers it. And then there’s system 2 which actually thinks about things.

Let’s try another warm-up:

A bat and ball cost $1.10.

The bat costs $1 more than the ball.

How much does the ball cost?

Hint: it is not 10c. If the ball cost ten cents, the bat would cost $1.10 and so the total cost would be $1.20.

What is the point of this? Well, the first point is – I thought it was cool. The second point is, there is a feeling you get from activating the second system and logically working out solutions, it is not always comfortable, and it is what you should try to get used to as you will come up against it a lot in real problem-solving as you are going to have to use your system 2… a lot.

So on that note let’s take a look at some problem-solving strategies which whether you love them or not, might someday come in handy.


 

The Box principle

Dirichlet’s box principle states that if n+1 pearls are put into n boxes, then at least one box has more than one pearl. Pretty obvious, huh? As another real-life example, if there are three people in a room, at least 2 are going to be the same sex (in theory that is anyway).

You can recognize if you can use the box principle if the problem has a finite set, it sometimes works with infinite sets too but if you know how many in a set then this principle might be possible to use.

Problem:

In a tournament with n players, everybody plays with everybody else exactly once. Prove that during the game there are always two players who have played the same number of games.

Spoiler Solution:

A player (pearl) goes into game (box) #i if they have i games. We have n players, and n games numbered 0, 1 , 2, 3, … , n-1. But the games with the numbers 0 and n-1 cannot both be occupied. So there is at least one game with more than one player.


 

The Invariance Principle

This problem-solving strategy is built on the principle of looking for what doesn’t change when an algorithm is repeatedly performed. So basically it can be used to quickly suss out whether a result is even achievable.

Here’s an example question where the invariance principle can be applied…

Problem:

A dragon has 100 heads. A knight can cut off 15, 17, 20, or 5 heads with a single blow of his sword. Immediately after, 24, 2, 14, or 17 new heads, respectively, grow back on its shoulders. If all heads are chopped off, the dragon dies. Can the dragon ever die?

Spoiler Solution (resist the urge to read it before you give the problem a go with your system 2!):

Look at the net change in the number of heads with each blow. If we cut off 15 heads and 24 grow back, the net change is +9. Similarly, -17 and +2 result in a net change of -15. Similarly, -20 +14 = -6, and -5 +17 = +12. The trick is to notice how all four numbers, +9, -15, -6 and +12, are divisible by 3. Another way to say it would be that the number of heads is invariant mod 3. The final observation we need to make is that 100 is not evenly divisible by 3. This means that no matter how many times or which blows we make, the dragon will not die, and will plague the village for years, so knowing this you know that it’s best to use a strong poison or White Walker magic.


 

The Extremal Principle

Also known as the variational method, this principle is good for proving the existence of an object with certain properties. The principle tells us to pick an object which maximizes or minimizes some function. The resulting object is then tested for the desired property.

Problem:

Imagine a chessboard that contains a positive integer in each square. If the value in each square is equal to the average of its four neighbors to the north, south, west, and east, prove the values in all the squares are equal.

Solution:

Consider the square containing the minimal value. Then its four neighbors must all have this minimal value. Similarly, their neighbors must also have this minimal value, and so on and so on to infinity and beyond. Thus, every square in the chessboard has the same value.

One more problem:

Every participant of a tournament plays with every other participant exactly once. No game is a draw. After the tournament, every player makes a list with the names of all players, who

  1. Where beaten by them (the player)
  2. Were beaten by the players beaten by them

Prove that the list of some player contains the names of all the other players.

Solution:

Let ‘A’ be the participant that has won the most number of games. If ‘A’ doesn’t have the property of this problem (won all of the games played), then there would be another player B, who has won against A and against all players beaten by ‘A’. So ‘B’ would have won more times than ‘A’. This contradicts the choice of ‘A’. So what you are doing here is testing the highest possible results (the extremal) which is the top winner winning all their games, if they cant meet this then the chances of anyone else doing it also falls down.


 

Enumerative Combinatorics

Enumerative combinatorics is an area of problem-solving the number of ways certain patterns can be formed. A better word for this type of problem then is “possible combinations” or even simpler “finding patterns”.

If you have ever watched the film Good Will Hunting, well, “It’s not your fault” as it is a pretty good film about how construction workers all secretly love solving the most complicated math problems while they scrub floors; if I understood the meaning behind the film correctly. What you see on the chalkboard in the hallway is not a rubbish stick spider picture but Cayley’s formula for the number Tn of labeled trees with n vertices.

Problem – Cayley’s formula for the number Tn of labeled trees with n vertices:

A tree is a non-orientated graph without a cycle. It is called labelled if its vertices are numbered… Yep, I went there. If you think that is hard to understand, try and understand the Wikipedia article on it: https://en.wikipedia.org/wiki/Cayley%27s_formula. What it is basically saying if I understand correctly is how many ways can a tree be labeled in different combinations. So to work it out we need to make a formula for Tn .

There is only one way to label a tree with one vertex, and the same for one with two vertices as the tree is not orientated. But for three points there are three possible ways of labeling, for four points there are 16 ways to label 12 different ways of labeling the chain and then four ways of labeling the star.

So then if we have five potential points there are 60 ways to label the chain differently, a star can be done five ways, then there is a way to intersect the points which comes to 60 different combinations. So this means there are 60 + 60 + 5 = 125 ways.

n 1 2 3 4 5
Tn 1 1 3 16 125

So if we suppose that this goes on indefinitely, we can try and work out the formula.

So it in each case is going up by one more times of itself. 3, 4 x 4, 5 x 5 x 5. So the guess would be 6 x 6 x 6 x 6. Get your notebook out and start trying to see if this holds for 6… it does.

Solution:

But unfortunately we need to make this into an actual equation so using my ancient math from  school – this means 6 to the power of 4. 64, but now we have to make a universal equation, so it becomes Tn = nn-2. And you can see for each number this equation actually works and we can sit and bask in our glory of solving a problem, why is the problem solved? Because you now have an algorithm to solve this question regardless of what input you have.


 

To really problem solve we should probably know about all the other points conducive to problem-solving and their relationships with problems and how they can be approached to resolve problems. But, life is short, if I run into trouble, I will google it and hope someone much smarter than myself has an answer.

Also if you want to get into the real nitty gritty and be completely well rounded in problem-solving you are going to have to know how to use and work with the following kinds of fun logical types of things:

Functional equations
Sequences
Polynomials
Inequalities
Geometry

But these are future problems.


 

Thinking differently

For now, let me leave you with one final problem:

Without letting your pencil leave the paper, draw four straight lines which go through all the following nine dots?

think outside the box puzzle

Impossible right? Looking at the problem you may infer that there are limits that have been put on you, like that you need to keep all the lines within the confines of the box that has been drawn, but like all problems in life, the limitations on how you approach a solution are all self-imposed if it works, it is not wrong. Right?

Solution:
Think outside the box, literally.

think outside the box solution

 

The problem is not the problem.

The problem is your attitude about the problem. – Captain Jack Sparrow

Posted in Education | Tagged , | Leave a comment

Developing the basics: Programming myself post twelve

treasureMap_12

CS50 review part II

<< Read the previous post from this series        Read the next post in this series >>

Finally!

I have finished the CS50 course. The future is there for the taking. I won’t lie this was a big undertaking. I think though overall this was a really good course to get through as it covers a lot of computer science principles, helps you to get familiar with some of the most useful developer technologies and makes you think harder about computer programing and computers and what is happening under-the-hood. There are a lot of directions to go from here and things to build on, though there is still a lot to do with Python I am definitely not finished yet.

 

What to expect

This is a huge commitment to your time; I would say that each week will take about 10 hours to get through. So it is some hard study, and you need to make sure you keep to a schedule as it is easy to put things off. I didn’t manage to do all the problem sets, to be honest, and I think in reality these are going to give you the biggest gains, but the lectures and examples will provide you with an incredible understanding of what is going on and why in your computer, but the coding you are only going to learn from the practice with the problem sets as just following lectures and thinking you can code won’t work.

 

The best bits

The Shorts are also incredibly interesting for an overview of the different concepts covered in the lectures. The concepts and technologies covered are great too as you get introduced to really interesting things and shown how to use them together with each other, for example, it is possible by the end to make a website which has a back-end which will react to the things you do and can store information. But what is better is that you can understand all the things going on and how they are getting their information and reacting with each other.

 

Drawbacks

So my original plan was to learn Python, this has deviated somewhat with taking this course as now I know a bit of C, Linux command line, HTML, JavaScript, SQL, JQuery, JSON, Flask, CSS, BootStrap, machine learning, image recognition, and generally how the internet works. But I think all this is actually worth learning if you want to become a computer programmer, the course also leads you through the process of finding out more information for yourself. There is a lot to get through; you have to take it week-by-week doing all the extra work and problem sets to get the most out of it. It doesn’t show you everything about each concept, but it does give you a foundation which you can build on right away.


 

Week 5 – Data structures

week 5 sketchnotes


 

Week 6 – the internet

week 5 sketchnotes the internet


 

Week 7 – Machine Learning

week 7 scetchnotes machine learning


 

Week 8 – Python

week 8 sketch notes Python


 

Week 9 – SQL

week 9 sketchnotes SQL


 

Week 10 – JavaScript

week 10 sketch notes


 

Now we are done with this course it is time to get back on track with the Python learning and getting through the next course “Adaptive Python” from the Stepik platform using the PyCharm Edu.

 

“When you have a great and difficult task, something perhaps almost impossible, if you only work a little at a time, every day a little, suddenly the work will finish itself. – Karen Blixen

Posted in Education | Tagged , | 1 Comment

Developing the basics: Programming myself, post eleven

treasureMap_11

CS50 review part I

<< Read the previous post from this series  See the next post in the series>>

The Harvard University computer science course CS50

This course has been highlighted by a lot of resources as a great jump off point for programming and I have to give it its due, this fame is well deserved. If you are coming to programming with no prior background it will take you through the concepts of computer science and familiarize you with the most important aspects. The lectures move fast, especially if you watch them in 1.5x speed as I did, as they are pretty bloody long typically 1hr 45 minutes, so you need to really concentrate which can be difficult. If you take 3 minutes after the lecture to try and summarize to yourself the points of each lesson you will retain what comes at you better for gaining some very useful and practical information about computer science.

What is especially awesome in the course are the “shorts” which go into the details of the concepts mentioned in the lecture and really help to cement what you need to know. This really is an enormous course to cover and does a great job of covering such a massive subject, from the lectures alone you will get a decent insight into a broad range of topics. It starts off teaching you about the C language which it uses to familiarize you with Linux, compiling and all the programming concepts like datatypes, operands and all the other foundational parts of programming. Then as an unexpected treat, the lectures move into other aspects of computer science, like the internet and other programming languages such as Python HTML and CSS. So you get a really great overview of a lot of different things.

The problem sets are very well thought out and really make you put your new knowledge into action improving your problem-solving skills. My biggest problem though is this course will take quite a lot of time and effort to finish. The problem sets are challenging and will take a lot of time to do, I mainly took the lectures, to be honest, and left out most of the problem sets, which is terrible… but being against the clock I found I didn’t have enough time for all this too. I do plan to go back to them simply because they are the main part of this course in terms of learning programming. If I was a full-time student though this would be the perfect course, as it has it all: problem-solving, background, and good explanations. But if you are going to go for this and see it through, it will take some dedication.

I will be covering more on CS50 in the coming weeks, but here as an introduction, you are welcome to check out my raw sketch notes, to inspire you, help you revise the course, and hopefully not horrify you too much with my handwriting and drawing skills.


Week 0

Introduction to binary and algorithms, and pseudocode

cs50 week 0


Week 1

C, compiling, functions, overflow

cs50 week 1 notes


Week 1 continued

C, compiling, CS50 tools, debugging, string and arrays, cryptography

CS50 week 1 part 2


Week 2

Strings, searching, sorting, running time, sorting

CS50 week 2


Week 3

Swapping, strings, memory, images

CS50 notes


Week 4

Structs, memory, debugging, data structures, stacks and queues, trees.

CS50 week 4

 

The privilege of a university education is a great one; the more widely it is extended the better for any country. – Winston Churchill

Posted in Education | Tagged , | 1 Comment

Developing the basics: Programming myself, post ten

treasureMap_10

A-Z of technical coding terms

<<Read the previous post from this series       Read the next post in this series >>

After 12 weeks of computer programming, you come to get to know some common lingo which you can use to impress your Nan with over breakfast. Here is an A-Z of some terms to get you through the day. If you are wondering how the studying CS50 is going… it is hard, interesting, fun, and repeat.


A – Algorithm

The specific instructions used to achieve a specific task. In the workflow, it would go:

Input > Algorithm > Output.

There are better algorithms to achieve certain things. See https://en.wikipedia.org/wiki/Analysis_of_algorithms for more information on this though. In a high-level language, you don’t have to worry too much about these recipes as they are done for you, all you have to do is call a function like sort() and not worry about what is going on under the hood. Unless of course, you are into that.


B – Boolean

True or false, yes or no, on or off, Boolean is concise as these options take a byte to perform.


C – Compile

Your source code is not what gets read by the computer. It is in a different language, kind of like if you wanted to try out your new French skills, but the only sentient being you could find was a shark, exactly like that.

Compilers change the source code into something called machine code, then this machine language goes on to communicate in binary to the computer. Luckily in Python, you don’t need to worry about this as it communicates through an interpreter, kind of like being able to call Aquaman in the scenario above.


D – Datatypes

Python has five standard Data Types:

  • Numbers
  • String
  • List
  • Tuple
  • Dictionary

Each has its uses and benefits, strings are used for letters and text usually, numbers are simple specific numbers. Int, long; float; complex. Lists, Tuple, and dictionaries are great for storing banks of information.


E – Events

Unfortunately making a button doesn’t mean it will actually do anything. Events are used to make it possible to interact with the code. So it will execute when something is done.
Command = button_click
Def button_click():
print(“stop touching me!”)


F – Function

The key to DRY code (Don’t Repeat Yourself). Functions are reusable code which you can pass in parameters. You have to define a function before you use it though, as the code will call back to the function when it is used. If you have to do the same calculation, use the same values, or something similar, then you should try and use a function.


G – GUI

Graphical User Interface. Making code that runs in its own app is much more interesting than having to run and see everything in the console. Python has some built-in GUI components that can be imported, Tkinter, for example, is awesome.


H – High-Level language

A computer programming language which has been designed to be easy to read by humans, like Python.


I – Iteration

Repeated execution of a set of statements. This can be done either with a recursive function call or a loop.
While loops or for loops, that is the question.

While loops are used if you want to have at least one result, they will usually run forever until an event is reached, iterating over the same code each time until that result is met.

For loops, on the other hand, are good if you want to repeat something a specific number of times.


J – Just-in-time (JIT) compiling

A way to dynamically compile some bits of an application during runtime. In Python you can use numba which supports CPU and GPU execution optimization, this means that for certain operations you can use your video card to process the results. JIT can make your application faster as there is much more information available at runtime.


K – Keys
Not only do keys open doors and treasure chests. They also open up some possibilities to play with hashes (Dictionaries).


L – Libraries

Import libraries and unlock the functions and tools created by people who have been doing this kind of thing a lot longer than me. This means you can use the best algorithms, contained in functions to do exactly what you want to do. Want to get access to a website and read the contents in it? There’s a function for that. The best libraries I have played about with so far are pygame and urllib.


M – Method

A method is pretty much the same as a function: it takes arguments and returns a value. If you have used something like aLittleSomething.something(), that’s a method. So you can basically invoke on something


N – Not equal to

!= and all its friends the operands can do strange things if left to their own devices == is not equal to = so tread carefully. It’s a trap.


O – Objects

Something a variable can refer to. An object combines variables and functions into a single entity. Objects get their variables and functions from classes. Classes are essentially templates for creating your objects. You can think of an object as a single data structure that contains data as well as functions. Functions of objects are called methods.


P – Programming idioms

There are tried and true, accepted, best practices for coding, different for each language. This is basically the code style. For Python you can find a lot of code style guides around, the following style guide is invaluable https://www.python.org/dev/peps/pep-0008/

Pythons design can be summed up in pep 20; the Zen of Python https://www.python.org/dev/peps/pep-0020/

The Zen of Python
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!


Q – Queues

A variable type which supports a first-in, first-out policy. So as data is added the oldest data is removed for example.


R – Refactoring

This is the act of making very small improvements to the code, things that don’t change the behavior of the code at all, but the sum of all the minor improvements adds up to a much greater improvement to the program as a whole. If you went into the working code and tried to improve it in one massive sweep, the chances are it will break the code, change the behavior or get you slapped by your team lead. Refactoring is very calculated and will make your code very clean.


S – Shell

The Python shell is known as the REPL which stands for “Read – Execute – Print – Loop”. It is basically the interactive part where you can see the outputs and errors and do basic things. If you create a GUI and forget to display message events to the GUI, the errors will be possible to see in the shell in the interpreter.


T – Testing

As I have found out, if your code only works 95% of the time, it basically doesn’t actually work. Testing the code to make sure that it does what you are expecting it to do, can be annoying, especially if you find that something actually doesn’t work. There are some tools you can use, for instance, built into Python there is unittest. Or you can just test to destruction, throwing everything at it until it breaks, then you can work out why and fix it… or call it a feature.


U – Unicode

Text is represented in files by encoding. 2 of the most popular types are ASCII and Unicode. The standard ASCII character set only supports 128 characters so it covers the English alphabet but that is all. Unicode supports up to 4 bytes for each character so it can cover about 100,000 characters, so is great for all the special characters in other languages like Chinese. Why am I saying this? 2 reasons really. 1 – I can’t find anything good to use for the letter U. And 2 – because you will likely come up against exercises which require you to capitalize characters, it is possible to hack something together where you can say -32 from the bit and it will give you the character in capital. A is 65, a is 97, 97 – 32 = 65 == A. But this won’t work for Unicode, so it is good to be aware of other problems which might come up.


V – Variables

Variables exist in different scopes. There are:

Local variables
which can only be used in the functions they are in, and

Global variables
these can be accessed by any function in the program. These variables need to be created outside of a function.

Python will let you access and read the value of a global variable. But it will not be at all happy if you then try to change the value of it. It will give you an UnboundLocalError. To be able to change it you have to make sure you tell your code that’s exactly what you want to do, by using global and then the variable in your function.
global nameOfTheVariable


W – Warnings

Warnings and exceptions are a part of the game. There are likely to be some that come up a lot.

Syntax errors – these will normally come up in the IDE – but they are things like:
Invalid syntax. An invalid syntax error means that there is a line that Python doesn’t know what to do with.

EOL or End Of Line – this error means that there’s an open quote somewhere and the line ended before it found the closing quote.
Unexpected indent – indentation matters; if something is indented at the wrong level then it won’t run properly in the function.

EOF or End Of File – this error usually happens if you forget to close the parentheses. Python reaches the end of the file looking for the closing parenthesis.

Runtime errors – these happen on running the code. Some common ones:
Name error – A NameError means that Python tried to use a variable or function name that hasn’t been defined yet. Mistyping a word usually leads to this, or not defining a variable before it is used.

Type error – a TypeError means Python tried to use a variable which is of a different type than expected. So, for example, a string to an integer.
“Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch. Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError.” – https://docs.python.org/3/library/exceptions.html


X – Pretty useful as a variable


Y – Also pretty useful as a variable


Z – 90 in ASCII

 

You have a faculty for defining the simplest in terms of the grandiose, so that a poor devil like me can’t understand it. – Malcolm Bradbury

Posted in Education | Tagged , | 1 Comment