Blog

Featured

Interesting Content From Across The Internet

Featured

Science seems to be suggesting that the evidence is currently pointing to the possibility that we are indeed living inside a matrix-like simulation, shaped in part by our consciousness. This video is a great watch for those with an open mind.

Archive

This video from Uplift talks about dealing with your inner world to improve your outer world, after all your outer world is a reflection of your inner world. Self awareness is a very powerful skill to develop.

This is a great video detailing how to be effective in your meditation practice. Susan Piver talks you through her recommended mediation process.

  1. Place attention on your breath,
  2. Openness – allow your thoughts to be as they are. Don’t try to fight them coming and going, just don’t let them distract you,
  3. When you notice you are being distracted, let it go. There is nothing to hold onto.

If you’re interested in persuasion, this is a must watch for you.

Watching This Video From Alan Watts Will Help You To No Longer Fear Death

Jim Carrey is a multi talented guy, as well as being hilariously funny in films like Dumb and dumber, Ace Ventura and many other popular movies, Jim is a great motivational speaker. This is one of his best talks, about how to think about living your life, enjoy

We are all the same under our “labels”, we are all members of the human race. Our “labels” act to separate and divide us, they try to fool us into thinking we are different to others, but in reality these labels are lies. We are more than our names, ages, race, religion, politics, our country of origin.. we are more than the colour of our skin. We are one, we are the human race….check out the video above for more insight.


 

Posted by Get Lasting Results on Tuesday, 29 December 2015
Goal setting is a key component for improvement. After-all you need to have at least an idea of the direction you’re heading. A direction-less life, without purpose is one without passion. Find out more about goal setting here

The cycle of behavior

A video posted by @getlastingresults on

I wrote abit about the cycle of behaviour here

Power Corrupts And Absolute Power Absolutely Corrupts

Get Results: power corrupts
Get Results: power corrupts

“Power corrupts and absolute power absolutely corrupts.”

It’s an interesting statement but is it accurate?

If you think about human nature we all have a tendency to gravitate towards inflating our sense of self, and avoiding situations that devalue it.

Evidence of this is all around us in everyday life. Arguments are engaged in to uphold ones sense of self. For instance, think about the reasons why you last argued, were you protecting something important to you? Something you’d invested yourself in. When you prefix “my…” to anything, such as“my idea”, “my thoughts”, “my opinion”, “my possessions”, “my kids” you make it part of your self-worth.

The mind believes, the more you HAVE the more you ARE, but the flip side of having more and being more, is that you also have more to lose.

When individuals gain more money, more power, more stature, it becomes more difficult to face loosing it, and so self interest and self preservation become even more important.

Those in power have more to lose by rocking the boat, by fighting again the very system they are benefiting from, so what do they do, they fight to preserve the status quo, because it serves them and after all, we are all designed to protect ourselves, it’s our survival instinct doing it’s job.

If you understand this trait of human nature, you come to realise that anyone in power is open to corruption, and is not going to drive through change that could potentially put them at risk.

You can’t defy human nature, we are what we are, but you can manage it, so that society is better for it, and so that those in power, serve society rather than themselves.

So how do we, the ordinary people, deal with the fact that people are self serving and power only increases this instinct?

Well, we start to actually hold politicians, businesses and powerful individuals to account, we make sure they deliver on the promises they benefited on the back of, and if they don’t they should know they have a great deal to lose.

Learn To Ask Better Questions

Get Results: ask better questions
Get Results: ask better questions

Asking better questions is a skill like any other, in that you get better with purposeful practice.

A while ago I read Warren Bergers, A more beautiful question – The power of inquiry to spark breakthrough ideas, and it got me thinking about the power of questions.

It’s an interesting read and builds on the idea of using the WHY, WHAT IF, HOW questioning system, which I love, because  it encourages expansive thinking.

I’ve used questions a lot in my life, in fact my wife is forever warning me to stop asking so many damn questions, particularly when we meet new people. I must admit, I do ask lots of questions, but not for any other reason than because I’m deeply interested in people and what makes them tick.

Get Results: ask better questions
Get Results: ask better questions

Maybe that’s why questions aren’t asked so much by many adults, we get used to adults telling us, as kids, to shut up and stop asking them.

There is no doubt in my mind that question are a gateway to finding things out. I ask my wife about things from her past, about where she lives and what she did, and what other people in her life did etc. It surprises me how little she actually knows about a lot of people she has shared her life with.

Now don’t get me wrong, people have a right to privacy, they don’t owe anyone else an explanation. I don’t mind people telling me to keep my nose out of their business, but I do believe that questions provide us with an opportunity to get to know others on a much deeper level.

Get Results: ask better questions
Get Results: ask better questions

People often seem content with superficial conversation about what they watched on TV the night before and what such-a-person is doing or saying. Gossip  can be quite interesting sometimes, although I try to keep away from it where possible, mainly because I don’t want to be viewed by others as a gossip.

However that level of conversation doesn’t really connect people to others, it doesn’t tell you much about who they are, apart from that they too like a bit of gossip or in some cases, thrive on spreading it, which gives a deeper insight into their personality, I guess.

Get Results: ask better questions
Get Results: ask better questions

Questions are also great for learning about ourselves, increasing self awareness. We may ask ourselves, why we do what we do and don’t do what we don’t do. What’s driving our behaviour? The answer’s, if given with honesty, can be very revealing. Sometimes people don’t ask these kind of questions, because they don’t want to know or admit to themselves, the answers.

It is surprising how much of what we do and don’t do is conditioned into us by social persuasion, often referred to as social conditioning. Conditioning is drilled into us throughout the duration of our lives, but particularly as young children, when we are particularly susceptible.

Get Results: ask better questions
Get Results: ask better questions

Questions are also a great way to spark ideas and innovation. Moving us away from the thought processes and work practices we have historically been accustomed to and instead opening up the opportunity to do them differently, and to find a better way. Why do we do it this way? What if we could do it that way instead? and then figuring out the HOW from that perspective.

Personally I like to use the following questions to remind me about not falling into the trap of doing anything that would be wasteful, unimportant or unfulfilling, when I would be better doing something else instead. I find it’s a great productivity tool. The questions should be asked in order.

  1. Why am I doing this, at all?  What is my goal?
    for example is it to make money, because it’s interesting to me, is it to gain or avoid something (such as not getting left behind or being able to add value to others). You should seriously consider this question and try to unlock your big WHY. This will help with the remaining questions. Use the 5 why’s method of questioning to dig deeper, so each answer you come up with, is followed by another  why, do this, you guessed it 5 times. Doing this delves down to the emotional background driving forces of your thoughts and actions, and gives you an opportunity to question these.
  2. What is the opportunity cost of doing it? What else could I be
    doing instead? Doing anything means not doing something else, both in terms of time constraints and economics, so consider what you’re missing out not doing. Remember time is the one resource we can’t recoup, once it’s spent.
  3. Is it worth the opportunity cost?
  4. Is there a better way of achieving my goal, instead of doing this?
  5. What other alternatives are available? Consider as many as you can!

So there you have it, questions are powerful, and if you haven’t read Warren Bergers, A more beautiful question – The power of inquiry to spark breakthrough ideas, I would highly recommend doing so, here is a link to Amazon where  you can read the reviews and even buy it.

Get Results: A more beautiful question
Get Results: A more beautiful question

 

Stay Inspired: Video Quotations

Get Results: learn, desire, action
Get Results: learn, desire, action

It’s important to keep motivated, and we can find inspiration all around us. People who overcome adversity and succeed, people who do things they don’t particular like, in order to reach a goal, people who never give up, no matter what.

I also love inspirational quotes, they give me a pick up, an opportunity to change perspective, and look at a challenge from a new frame of mind. I’ve included a few, and will be adding more video inspiration quotes to this page, so keep checking back. You can find them on my Instagram page also here.

Appreciate Your Now

Get Results: life is never not now
Get Results: life is never not now

I was recently talking to someone who was struggling to come to terms with a friend of hers leaving to join the army. The back story is that her best friend of 17 years had been living with an ex for 6 months due to financial constraints, and as a way out had decided to join the army and leave for 4 years with possible deployment oversees.

Apparently she would never have done this if she wasn’t stuck in this bad living situation, but has now become excited at the prospect of new beginnings.

The person I was talking to, let’s call her Elaine for the purposes of this post, was feeling angry and sad about her friend leaving, especially because she’d be leaving to potentially be part of a conflict and could find herself in great danger.

Although Elaine was being outwardly supportive of her friend, she was dreading her departure, and the thought of potentially losing their close friendship and had a lot of anger which was directed at her friends ex for putting her in this situation.

Elaine had a couple serious “are you sure?” conversations with her friend who had indicated that she was sure of her decision, and it being what she wanted.

If Elaine’s friend stays she will continue to work at her solid full time job, and will only have to keep living with her ex for another two months.

I told her the bottom line was she should let go of her attachment to their friendship and accept the situation as is, which involves both letting go, and surrendering to the present reality.

She shouldn’t resist the feelings she has. Instead examine her fear of loss by looking into it.

Bringing awareness to her story telling, by asking how much of it is speculation driven by fear, which is all of it, in reality. I told Elaine to be aware of this, and the fact that none of these thoughts are real, they are story telling embellishments out of control.

The truth is her friend is happy to go, so she should be happy for her. None of us know what the future holds, her friend could stay and get hit by a bus, and then Elaine would be thinking she should have let her friend go into the army after all, instead of talking her out of it. You can make stories up to either back her friends departure or for staying.

I advised Elaine to let go of the fear that is telling her that her friend is safer here rather than there. It’s her friends journey and she needs to go where she needs to go. We all have our own journey to travel.

We are all protective of those we love, we want them to be safe and secure, and when they are not with us we believe the danger is greater or that we may be left without them. This is of course a possibility, but we can drive ourselves crazy by running with these stories.

Loss is indeed part of life, all things are transient. Change is continuous and wishing for it not to be, does little to change the reality.

We should be grateful for the blessings we have, as they are happening, for the relationships, the places and the things we get to experience, in the moment we experience them. Instead of being completely absorbed by wanting, and chasing after more or better in the future, which many of us do, and are preoccupied with doing, only to realising what we had, but didn’t truly appreciate when we had them to enjoy. Nothing lasts forever, everything has it’s time and is subject to change, continually.

Accept the fact that change is part of life, be grateful for your blessings right now, and get used to the idea that the future is uncertain, but focus much more on the opportunities it can present, rather than the danger, and  risk that it may or may not pose.

The best solution is not to over think, but instead feel life in the moment it unfolds, in the present moment. Thinking is imagination, speculation, with no foundation in reality. It’s the creative story teller inside you, driven by fear. Love is now, fear is focused in the future. Appreciate all you have now. It’s fine to work towards a future goal, but prioritise NOW, and all that is in your now, because it might not be there tomorrow.

For more about spirituality click here.

For more about gratitude click here.

Enlightenment: Freeing Yourself From Thought

Get Results: Alan Watts Enlightenment quote
Get Results: Alan Watts Enlightenment quote

ENLIGHTENMENT comes from separation of AWARENESS and I INVESTED THOUGHT, particularly rigid thought forms such as BELIEFS. This realisation brings space to all situations, a gap to observe thought, but not be inside and part of thought.

It is impossible to go back fully to old thought habits once this shift takes place.

Thereafter the difficulty is dealiing with a society that is largely blind to this perspective and that continues to struggle along unconsciously, WANTING, ATTACHING and SEPARATING from it’s environment, seemingly insanely fighting over scarce resources, and desperately trying to be something different, better or somewhere else.

But that feeling too gets easier when you let go of EXPECTATIONS which after all are just thoughts.

It’s easy to forget, or fall asleep in some lazy moments and you risk becoming once again reactionary to your thinking, this is where some discipline and effort may be required.

It’s also tempting to try to over complicate enlightenment, because it seems too easy a process, to remove pain and suffering, but it is this easy if you remove your sense of self from your thoughts.

See the importance of the moments as they unfold, keep from wishing for the next moment to come or dwelling on your past.

Feel connected to and one with life itself.

Allow joy to flow into what you do, or at least accept the things you can’t enjoy as you do them.

Enthuse with all that is, right and wrong, front and back, up and down, black and white, for everything has it’s place, in the rich tapestry of life.

LIFE is about experiencing the good and bad moments, riding them like a wave, rather than fighting with all your might against them, being in those moments as experiencing energy, and following your bliss, wherever it takes you.

Find out more about spirituality and wellbeing here.

Something Valuable To Learn From The Story Of The $20 BIll

Get Results: storytelling is the oldest form of education
Get Results: storytelling is the oldest form of education

We all love interesting stories, it seems to be built into our DNA, our ancestors told them through the use of fables and parables. I particularly like parables, designed to teach us something morally or spiritually. I like the  story of the $20, which is modern setting for a  timeless lesson. Hope you enjoy the story of the $20 bill…

Get Results: the $20 bill story
Get Results: the $20 bill story

Stop COMPLAINING And Start GAINIING

Get Results: stop complaining and start gaining
Get Results: stop complaining and start gaining

If you’ve spent any time on social media , you’ll know  that it’s full of complainers and blamers. People whinging about this and that, and boy have they had stuff to whinge about over the last few years.

There’s been Brexit here in the UK, Trump’s rise to power in the US to name just two biggies that spring to mind.

There’s also complaints about local stuff, like congestion, poorly planned urban development, anti-social behaviour, lack of courtesy on the roads, traveling communities disrespecting local areas.

Some complain they are getting the thin end of the wedge with student loans, job prospects, housing market conditions, I could go on and on.

While I have sympathy for those that find themselves on the receiving end of such situations, I too have been impacted by some of these things, complaining, and blaming doesn’t help in finding a solution, other than acting to alert those willing to take action, that a unsatisfactory situation does indeed exist. I guess that’s what complaining is designed to do, force others to take action on your behalf, whether that be local councils, politicians or the community itself.

I don’t suppose complaining is going away anytime soon, but for those that would like to take a more empowering position, read on…

Get on the right side of how things work, as Jim Rohn is famously quoted in saying. I would add that it’s important  to realise that there are winners and losers in every situation. You can be a victim or a victor. Sure sometimes things blindside us, we just didn’t see them coming, but we do have a choice in how we deal with them.

Be a predator of chance rather than a victim of circumstance, and look for the opportunities that come about continually because of the fact things are constantly changing.

Get Results:predator of chance rather than a victim of circumstance
Get Results:predator of chance rather than a victim of circumstance

It’s natural to fear change, because it brings with it uncertainty and risk. We, as a species have evolved to favor the tried and tested approach to ensure our own survival, and this is hard to shake off.

However with a shift in perspective, we are able to see that there are also many opportunities that come from change. When you choose to focus on opportunities rather than fear, you see things you wouldn’t otherwise see.

Let me give you an example, there are people still moaning about Brexit over a year after the decision has been made, they are still fighting an old fight, instead of focusing on making the best of it.

I  still see people going on about the disaster that will befall us when sterling comes crashing down around our ears, on exited the EU.

I say if you’re so sure of a future outcome take advantage of it instead of complaining.

For example – If the pound is going to plummet, because of Brexit, sell as much money as you can get hold of and buy a competing currency, like the Euro, you’ll make a fortune if you’re right. That’s a case of going from victim to victor in one foul swoop.

Any fool can moan and complain, but it takes someone with a bit of nowse to look for opportunities instead of being fearful of what could go wrong. If you’re certain of a future outcome, you’d be crazy if you didn’t move to take advantage of it.

But if you aren’t as sure as you make out on social media, give it a rest pretending you are. It’s not helpful, it doesn’t provide solutions to the situation as it is today.

For more about  taking responsibility click here.

Having Beliefs Worth Dying For

Get Results: seek the truth
Get Results: seek the truth

I recently commented on a post, that talked about how even people who believe themselves to be ENTITLED are often attached to beliefs, because they have invested a sense of themselves in these beliefs, and when challenged can become aggressive, and closed off to competing narratives, because defeat would somehow make them feel their sense of self to be less.

This is important because this mental positioning is what leads mankind into conflict and ultimately war. Now I’m not saying we are all capable of killing others to defend our beliefs, but given the right circumstance it is possible that even so called level headed, model citizens are capable of contributing to unimaginable things. Mankind’s history is littered with examples. World War 2 for instance, is often blamed on the Nazi party under Hitler, but we have to remember that German people voted him into power, because they believed his rhetoric, and the narrative that Jewish people where the problem.

The following conversation ensued, I thought I would make a post about it, because this is a good illustration of what happens when you attach to beliefs, now there’s no chance of this escalating into war or anything so extreme, but it hopeful shows how division starts, because one person feels threatened by the ideas of another, because they are invested in their beliefs..

Me: A belief in anything risks investing yourself in it. As soon as anyone feels the need to defend their belief they have probably gone too far.

Other: But what good is a belief if you are unwilling to defend it? I don’t ask anyone to become a Buddhist or think the same, but if they challenge my core beliefs, such as work telling me to take a sentient life, I will defend my beliefs to the end.

Me: and there lays the Ego dilemma. It is for the individual to pick their own path, but as long as you choose to defend your beliefs you automatically invest yourself in them. This is Ego at work. Beliefs forge separation (from contradictory beliefs) and form attachment (to the belief), both are designed by the Ego to make yourself more, because the more you have the more you are. Why would a person need to be more, if you were truly enlightened? I’m open to contradictory views, I don’t invest myself in this way of thinking, it’s just the best explanation available to me at this moment.

Other: this is not allowing another to breach my beliefs. It has nothing to do with ego. There is nothing wrong with belief and faith. It is what makes us spiritual and follow an ethical path. Without belief we are nihilists.

Me: I’m just saying we should be open to the possibility we might be wrong. Seeking the truth, rather than settling for something that could be wrong, and closing ourselves off from the truth.

Other: why do you assume that I have not investigated multiple beliefs and religions? I do not create my beliefs out of just accepting what my parents told me. If I did, I would be a Christian. I take refuge in the three jewels because of my investigation into truth and logic. Yes I am invested in my beliefs.

Me: I’m not assuming anything, I’m not judging you in anyway. You commented on my comment. I hope what you believe serves you, but that alone doesn’t make it THE TRUTH, but it is your best guess, as is my view for me.

Me: Many beliefs are built on assumptions, inferences and the testimony of others, rather than FACT. What actual facts back up your beliefs? (that is a rhetorical question, I don’t expect you to list them) but ask yourself this question for every belief you hold. We all should do this. Many of the BIG questions we have about life, can’t be proven as fact, there is often a lot of faith involved, so they are effectively guesses, we hold to be the truth.


Now I wasn’t trying to be a smart ass in this conversation, or attack the other persons beliefs, but he or she seemed to take it that way to some degree and the impression I got (which is often difficult to accurately gauge via a text only medium) is that they were agitated by my comments just a little bit, and as a result felt a need to defend their position. The comment about Christians just believing what their parents told them, could be construed as a dig at a different belief system, but generally I think we both approached this conversation with a balanced view.

I dare say if I’d have framed my language more aggressively, and the other person, likewise, this could have got into something of a slanging match, like we see all too regularly on social media.

My comments during the short conversation weren’t a criticism of the other person but a general statement that all of us should be very wary that our beliefs don’t close us off to competing ideas. It’s like a barrier goes up and perceptions are closed down. I liken it to a child covering their ears and humming to prevent hearing what is being said.

Hey, I’m as guilty as anyone else, for defending my beliefs in the past. I now have a different view of them, or I could even say I have a different belief about beliefs. You can’t get away from holding beliefs, they’re kind of an anchor for us to build from.

The problem seems to come from investing yourself in them, as I said in the conversation above.  But it is important to realise we often take what we need from our beliefs and ignore the rest. However this isn’t the best approach for uncovering THE TRUTH. Scientist generate an hypothese, and look to disprove it. The scientific approach prevents confirmation bias, and investment in the belief. It’s a best guess, until proven otherwise approach.

I have become very wary of anyone who says they have strong beliefs, that they would defend with their very lives, because I believe them.

For more about improving self awareness, check out these posts

They’re Fooling You, Start Living The Life You Want

Get Results: focus on making a life
Get Results: focus on making a life

It’s time to wake up to the big lie.

If you only do what you truly love for a fraction of your waking life, because you have bills to pay, and other obligations, what kind of life are you really living? I mean seriously think about this for a moment.

Cutting costs is as good as earning extra income. Drop the excess to focus on the things that really matter to you.

Happiness doesn’t come from possessions, or having more stuff, because once you have them, and once the novelty wears off, it becomes part of the norm and you will tend to look towards the next new or better thing.

Marketers and the businesses behind them want to feed you the narrative that having more will make you happier, will enrich your life, and they do this because it serves them, not you.

WANTING is conditioned into us, and HAVING is the dream, but this is a lie.

Instead focus on BEING. experience life, get out of your head and into the experiential reality of life. Serve your soul, by enjoying the experience of people, places and pursuits that excite you and that bring you joy or should I say, you enthuse joy into doing.

Figure out a way to pay the bills you have to pay, the necessities, minus any unnecessary excess, while doing the things that allow you to BE true to yourself. This is the way you should be defining success or lack of.

Get Results: wheres you path taking you
Get Results: wheres you path taking you

It’s time to change perspective, to re-evaluate your financials, and live a life that truly engages you.

 

 

Learning To Code – Acquiring Knowledge And Developing A Skill

Get Results: coding
Get Results: coding

As part of my own journey of self improvement, and the subsequent creation of this website, I’ve worked at putting many of the sites teachings into practice. It’s made a huge difference to my business, my relationships and my general outlook on life.

As part of this process, I’ve opened myself up to doing new things. One of these new things has been learning to code.

Historically I’ve convinced myself that I’m not the type of person to be a coder, and have failed to be able to get into it. I now realise this to be a coping strategy and an attempt to not have to take responsibility. Kind of saying to myself “If god hasn’t designed me to be a coder, I guess he knows best”. This allows me to psychologically move on to something else.

However, I’m now a little wiser and certainly more self aware, I can admit I’ve been closing myself off to the challenge.

I’m now open to the challenge and the surprising thing is, I’ve really enjoyed studying it. There is so much to learn it can be overwhelming, but also really exciting, with regards to the headroom for learning and the future possibilities for coding.

The key skill to programming is the ability to solve problems. I like solving problems, as well as helping people, so coding is a good fit for me personally as it aligns with my core purpose.

So where to begin? After doing some initial research, and asking a couple of programmer friends of mine (who have subsequently become mentors), I came to the conclusion Python would be a good starting point. I like the idea of data mining , deep learning, AI etc and Python ticks many of these boxes. It’s also a high level programming language, which means it operates at a higher conceptual level, and this really appeals to me.

I realised that web based applications would also be possible, but figured learning more about JavaScript and PHP would be worth investigating. I was informed by one of my mentors that it’s relatively easy to pick up a second language once you have one under your belt, and this has subsequently proved to be the case.

I scoured the internet, particular Youtube to find easy to follow tutorials. Not having anything of a coding background, I found some of the terminology rather difficult to come to terms with, but  with plenty of patience and determination, I’ve been able to power through these challenges.

I figured it best to learn the basic building blocks of the language, which I’ve detailed below, this isn’t designed to be a comprehensive list, but to give you an idea of what is involved in the learning process. It also helps me crystalise my learning, because I’m a firm believer than if you can’t explain it simply, you don’t understand it well enough.

Hopefully you have gained some insight from my experience, and don’t shy away from learning new skills, I’m 50 years old and prepared to learn a completely new skill set at my age. It’s never too late.

The important thing to remember is not to get overwhelmed, or try to run before you can walk. Be patient, understand the fundamentals well, before progressing. Play with and enjoy the learning experience for it’s own sake, and not for what you will gain at the end. It’s about the journey, not just the destination.

If you’re not particularly interested in coding, you don’t need to read this post any further.

Learning the fundamentals of Python

I’m not going into the details of installing Python, there are many resources online detailing the exact process, other than saying you input  your code into Idle, which comes along with the Python installation.

“#” is a comment, it’s not part of the code, but allows you to add important notes to help readability and explain what you’re trying to do on each bit of code.

Variables

A variable is simply a pointer to something in memory.

Python variables do not need explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.

The syntax is such that the operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable.

So “myVariable” in the example below is the variable name, it should have no spaces and not start with numbers. variable names can only include a-z, A-Z, _, and 0-9. Other special characters are not permitted.

myVariable = "Hello World"

# this is a comment, and not part of the code. If you want to print the result to the screen do the following..
print(myVariable)
another_name = "Hello World" 
print(another_name)

Both the above examples print out “Hello World” to the screen. The variable name can be anything you want it to be, but make sure it’s descriptive enough so you and anyone else can understand the code at a later date.

Values can include strings (including sentences) which appear inside “”, numbers (including integers, floats, complex number) , lists which appear inside [], tuples () or directories {}, and we’ll cover these data types later. Here are a few examples

randomNumber = 400 
print(randomNum)
randomList = ["money", 43, "red", "UB40"]
print(randomList)
randomTuple = ("money", 43, "red", "UB40")
print(randomTuple)

Functions

A function is a block of reusable code that is used to perform a single, related action. Functions are convenient for reusing, without having to write the code out again and again later in a program.

The syntax for functions can be seen below; start with “def” and are followed by the function name (you choose what) and parentheses  ( ).

The code block within every function starts with a colon : and is indented. The indentation is very important, it will not work otherwise. Indenting code is done by pressing space bar 4 times on new line.

The bottom line below “calls” the function.

def bitcoin_to_sterling(btc):
    amount = btc * 3714.76
    print(amount)
bitcoin_to_sterling(10) #this line calls the function

# this function replaces btc with 10 which is multiplied by 3714.76 = 37147.6
def greet_user(username):
# Display a simple greeting
    print("Hello, " + username.title() + "!")
greet_user('mike') #this line calls the function

# this function prints out "Hello Mike"

Conditionals : if – elif -else

Conditional statements are common among programming languages and they are used to perform actions or calculations based on whether a condition is evaluated as true or false. If then else statements or conditional expressions are essential features of programming languages and they make programs more useful to users.

x = 14 
y = 14
z = 5

if x < y:
    print("X is less than Y")
elif y < x:
    print("Y is less than X")
elif z > x:
    print("Z is greater than X")
else:
    print("Y and X are the same and Z is less")

# prints out "Y and X are the same and Z is less"

Loops

A loop is a programming construct that enables repetitive processing of a sequence of statements. Python provides two types of loops to its users: the “for loop” and the “while loop”. The “for” and “while” loops are interation statements that allow a block of code (the body of the loop) to be repeated a number of times.

# WHILE loop example
condition = 1 # variable
while condition < 10:
    print(condition)
    condition += 1 # just keeps adding 1 until condition is met up to 10 but not including 10
# FOR loop example 
colours = ["red","blue","green","yellow","orange"] # this is a list

# this is for actual FOR loop
for colour in colours:
    print(colour)

Lists

We’ve used a list in the previous example for loops

A list is a data type that can be used to store any type and number of variables and information. You can manipulate lists, adding, removing, sorting, deleting contents.

# FOR loop example 2 - manipulating the original list

colours = ["red","blue","green","yellow","orange"] # this is a list

# add to end of list
colours.append("pink")

# replace an item on list
colours[0] = "pink"

# insert into list
colours.insert(1, "pink")

# delete from list
del colours[0]
colours.remove("pink")

# sort list
colours.sort()

# reverse list
colours.reverse()

# this is the actual FOR loop
for colour in colours: 
    print(colour)

Tuples

Tuples are fixed size in nature whereas lists are dynamic. In other words, a Tuple is immutable whereas a list is mutable. You can’t add elements to a tuple. Tuples have no append or extend method.

A Tuple is created by placing all the items (elements) inside a parentheses (), separated by comma. The parentheses are optional but is a good practice to write it.

A Tuple can have any number of items and they may be of different types (integer, float, list, string etc.).

tup1 = ('physics', 'chemistry', 1997, 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )
print(tup1)
print(tup2)

Directory

A directory is like a list but instead of looking up an index to access values, you’ll be using a unique key, which can be a number, string, or tuple. Directory values can be anything but the keys must be an immutable data type. A colon separates a key from its value and all are enclosed in curly braces. Here is the directory structure:

 d={key_1:a, key_2:2, key_3:ab}

menu = {"spam":12.50,"carbonara":20, "salad":15}
print(menu)
print(len(menu)) # 3

Classes and object-orientated programming

Python is an object-oriented programming language, as it manipulates and works with data structures called objects. Objects can be anything that could be named in Python, such as  integers, functions, floats, strings, classes, methods etc. All these objects have equal status in Python. They can be used anywhere an object is required.

You can assign them to variables, lists or directories. They can also be passed as arguments. Every Python object is a class. A class is simply a way of organising, managing and creating objects with the same attributes and methods.

class Employees(object):
   def __init__(self,name,rate,hours):
   self.name = name
   self.rate = rate
   self.hours = hours

staff = Employees("Wayne",20,8)
supervisor = Employees("Dwight",35,8)
manager = Employees("Melinda",100,8)

print(staff.name, staff.rate, staff.hours)
print(supervisor.name, supervisor.rate, supervisor.hours)
print(manager.name, manager.rate, manager.hours)

Opening, Reading and Closing text files

One thing you’re likely to need to do with Python, is manipulate external files, below is some code for  opening, reading and closing text files.

There are many libraries you can call upon to add functionality to your Pyhton code, such as NLTK, which help you deal with other file types, such as HTML (webpages), word documents, PDF files, electronic books etc.

# open and read from text file
f = open("test.txt")
#print(f.read())
# create and save text file
with open("list_created.txt", "w") as output:
 output.write(f.read())
# reading file
f = open("start_days.txt")
print(f.read())
# writing file
title = "Days of the Week\n"
days_file = open("start_days.txt", "r")
weekDays = days_file.read()
new_days = open("new_file.txt", "w")

new_days.write(title)
print(title)

new_days.write(weekDays)
print(weekDays)
# closing file
days_file.close()
new_days.close()
#changing external variables (string/interger combination) from a text file into a
#directory by defining key and value
mydict = dict((k, int(v))
for k, v in (e.split(' = ')
for e in days.split(',')))

Below is a fun little program, I’ve made, putting some of the code learned above, into practice. It interacts with a user, and asks them to input a number guess into IDLE. It’s only basic stuff, but it’s a start, and practice makes perfect.

The inspiration for making this little game came from reading an article about a coder who was asked to do a program that asked a user to guess a predefined number between 1 and 100, and printed out onto the screen after each guess, whether the guess was under  or over the target number.

magicNumber = 20
number = ""

while number != magicNumber:
    answer = input("Pick a number between 1 and 100 ")
    number = int(answer) 

if number > magicNumber:
    print("Too high")
elif number < magicNumber:
    print("Too low")
else:
    print("Well done, you've got it right!")

Doing this little program tweaked my interest in the concept of interacting with a user, so I’ve spent some time learning Javascript as a results, because I am able to interact with website visitors more readily using Javascript. I’ll be posting something in the future to detail my experience with this web based language.

Here is a rather more complex program, which I’ve since rewritten in Javascript.

print("first get a piece of paper, right down two choices for a particular decision you have to make. Under each right down 3 attributes that are important in the decision. Think about the most important to least important. Now lets begin")
define1 = input("Define your first option as suscinctly as possible ")
feature1 = input("define an attribute that is important in this choice ")
weight1 = input("weight it's importance 1-5 , five being more important ")
weightone = int(weight1)
listing1 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most) ")
listingone = int(listing1)
result1 = weightone * listingone
print(define1)
print(feature1)
print(result1)

feature2 = input("define an attribute that is important in the choice ")
weight2 = input("weight it's importance 1-5 , five being more important ")
weighttwo = int(weight2)
listing2 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most) ")
listingtwo = int(listing2)
result2 = weighttwo * listingtwo
print(define1)
print(feature2)
print(result2)

feature3 = input("define an attribute that is important in the choice ")
weight3 = input("weight it's importance 1-5 , five being more important ")
weightthree = int(weight3)
listing3 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most) ")
listingthree = int(listing3)
result3 = weightthree * listingthree
print(define1)
print(feature3)
print(result3)

if result1 > result2 and result1 > result3:
    print("The most imporant attibute is " + feature1)

elif result2 > result1 and result2 > result3:
    print("The most imporant attibute is " + feature1)

elif result3 > result1 and result3 > result2:
    print("The most imporant attibute is " + feature3)

else:
    print("No winner")


define2 = input("Define your second option as suscinctly as possible ")
print("The attribute has already been defined as " + feature1)
weight4 = input("weight it's importance 1-5 , five being more important ")
weightfour = int(weight4)
listing4 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most) ")
listingfour = int(listing4)
result4 = weightfour * listingfour
print(define2)
print(feature1)
print(result4)

print("The attribute has already been defined as " + feature2)
weight5 = input("weight it's importance 1-5 , five being more important ")
weightfive = int(weight5)
listing5 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most) ")
listingfive = int(listing5)
result5 = weightfive * listingfive
print(define2)
print(feature2)
print(result5)

print("The attribute has already been defined as " + feature3)
weight6 = input("weight it's importance 1-5 , five being more important ")
weightsix = int(weight6)
listing6 = input("how important is this attribute compared to other attributes. If it's the most important score it 5, if it's the second most important 4 and so on (least 1-5 most)")
listingsix = int(listing6)
result6 = weightsix * listingsix
print(define2)
print(feature3)
print(result6)

if result4 > result5 and result4 > result6:
    print("The most imporant attibute is " + feature1)

elif result5 > result4 and result5 > result6:
    print("The most imporant attibute is " + feature2)

elif result6 > result4 and result6 > result5:
    print("The most imporant attibute is " + feature3)

else:
    print("No winner")

calculation1 = result1 + result2 + result3
calculation2 = result3 + result4 + result6

if calculation1 > calculation2:
    print("Of the two choices, the one that got the best score, based on your answers was " + define1)

elif calculation1 < calculation2:
    print("Of the two choices, the one that got the best score, based on your answers was " + define2)
else:
    print("There was no overall winner")

Check out my little random quote program, when you get onto it just click the button to reveal the next quote, which will stay visible for 10 seconds and disappear, just click the button again to reveal another quote. Keep the page bookmarked as I’ll be continually adding new quotes to it.