Friday 30 October 2015

My Progress: Semantic and Syntax Errors.

Semantic Error and Typographical Error.




When learning programming, no matter how smart you are, two types of errors are inevitable, they're semantic error and syntax error.

I am not new to programming, but it's been a very long time since I wrote something serious, so in other to avoid frustration while working on my prototype, I have decided to read a book on python it's titled Learning Python The Hard Way.

I am not reading this book as a newbie would read it because I know most of what is inside the book, all I needed was a revision of the terms and I would be good.

Oh boy, I was wrong!

Although, I can read a complex line of codes and understand what it does, I have issues getting my code to do what I want it to do.

What this means in simple term is that, even though when I write the code, the computer (interpreter) is able to interpret it, but the output it gives is not what I want.

You can liken this to pressing (5 + 2) on a calculator, while you expect the answer to be 7, but then you get 52 or 30. This is what semantic error is all about.

#This defines the function and receives argument variables.
def cheese_and_crackers (cheese_count, boxes_of_crackers):
total = cheese_count + boxes_of_crackers
""" The next few lines print the argument variables"""
print "\n You have %d cheeses! \n You have %d boxes of crackers! \n The total of your resources is %d:" % (cheese_count, boxes_of_crackers, cheese_count + boxes_of_crackers)
print "\n Man that's enough for a party!"
print "\n Get a blanket.\n"
def number_of_rooms (Available_rooms, Assigned_rooms):
Total = Available_rooms + Assigned_rooms
print "There are %d rooms in total" % Total
print "Only %d rooms are available" % Available_rooms
print "%d rooms are occupied already" %Assigned_rooms
print "Do you still want to party?\n"
print "We can just give the function numbers directly:"
cheese_count = int(raw_input("How many cheese do you have? "))
boxes_of_crackers = int(raw_input("How many boxes of crackers do you have? "))


print cheese_and_crackers (cheese_count, boxes_of_crackers)
print "Now that you're ready for party, answer these questions: "
Available_rooms = int(raw_input("How many rooms are available? "))
Assigned_rooms = int (raw_input("How many rooms are assigned? "))

print number_of_rooms (Available_rooms, Assigned_rooms)

print "Or, We can give the function numbers directly:"
amount_of_cheese = 10
amount_of_crackers = 50

cheese_and_crackers(amount_of_cheese, amount_of_crackers)

print "Let's do some math:"
cheese_and_crackers(10 + 20, 5 +6)

print "We can combine two the two; variables and math:"
cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)


The code would execute, but the output would be wrong.

I have many issues with semantic error because I failed to read python documentation (I decided to learn on the job because this might take a week to wrap my head around it). Even though the semantic error is slowing my progress down, I still prefer this method, because I would in a week or two get over the semantic error as well as gain the right thinking hat for python.

The other error; syntax error is the normal typos you make when you write a piece of code, with this kind of error, you code would not execute, which means it won't work at all; because you're speaking a language the interpreter does not understand. This error might be frustrating, but it's not as dangerous as semantic error. Since the code won't work until it is fixed, you can be rest assured that you're still making progress until you get what is wrong and fix it. Sematic error would fool you into shouting "Eureka" until you realize that the output is wrong.

When I began programming (Almost five years ago) I learnt the basis, and one thing I believe over the years is that, a program should be able to do more with very short lines. I believe how short (minimal) your lines of code is would determine how smart a programmer you are.

The python book am reading contradicts that believe. Basically, a good programmer is the one that can write a code that a novice would understand to some extent. It's almost impossible for a novice to undersstand your code if you don't add english comment at the end of every line. So I am working on my commenting skills, because this project is a prototype, and I might not be the only one who will work on it in the nearest future, so I need to make it understandable to others to some extent.

Initially, when setting up my work environment, I wanted to use python 3.0+ but I later decided against it because 2.7+ is much more stable and I would prefer a stable and well known environment that trying to figure out my way in a newly developed technology (YouTube and Instagram were built with 2.7+).

Progress so far?


  • Setting up python
  • Speed reading a book on python
  • Creating the functions
  • Copying, Editing, and Writing files with a single argument script.


I guess thats all for now, I would update this blog as I progress.

Monday 26 October 2015

Revamping Life: I Would Build A Prototype In The Next 8 Weeks!

I once heard a TED talk that discouraged people from sharing their goals before they achieve it, mainly for the fear of feeling it has been achieved (Effect of people praising your effort).

To some extent, I believe the theory proposed in the talk, on the other hand, I believe we as human tend to be more accountable of our time and action provided we tell others about our moves, we wouldn't want to come short, we wouldn't want to portray our self as a quitter, so when we set a goal and tell others about it, we would eventually do our best to achieve the said goal.


Based on this school of though, I have decided to share my goal for the next few weeks, and hopefully, I wouldn't end up quitting because am writing about it.

For the next eight weeks, I would be brushing up my skills in programming (Python and Django web frame work), the idea is to learn enough to be able to create a prototype for an web app I recently conceive.

Today, being the day one. I have successfully install python on my laptop computer, and I downloaded the book "Learning Python the Hard Way". I would frequently come here as time would permit to document my progress, and hopefully, It would be a great journey.



Thursday 15 January 2015

Clearing Cobwebs! I am still Alive!

Been ages! Since I updated this diary, if anybody is reading, be rest assured as I am still alive and not dead. A lot has changed about me lately, and I don't think I can write all the changes in a single post, I will probably share the changes as I update this diary every once in a while.

Am now a third year student! As a matter of fact, if everything work out as planned, I would be starting my penultimate year by March. The journey so far? Its been stressful, fun filled and challenging (I guess that's what uni is all about, right?) I have met bunch of people, made friends, and I am most grateful for this.

More details coming soon, before the week runs out. Until then, stay calm and meet the new me below....