Friday, June 15, 2012

Friday, 15th June 2012

Today reached school quite early, around 8
Waiting for class to start x.x

Didn't change group today cause teacher forgot

Today Communication Practice need do something about Air Force 1
I lazy elaborate lol

1 word to describe, troublesome

Managed to bullshit about my reflection journal for Communication Practice
Still got Air Force de need to bullshit, why need 300 words also sia
They really will read it de meh =.=

Thursday, June 14, 2012

Reflection Journal for Programming 06

The Question (from http://bit.ly/KxmVcS) :





























The Code :

# 4 line version

for i in range(0,10,1):
    print (i*'#') + (22 - i*2) * ' ' + (i*'#')
for i in range(10,0,-1):
    print (i*'#') + (22 - i*2) * ' ' + (i*'#')


OR

# 5 line version

def hourglass(a,b,c):
    for i in range (a,b,c):
        print (i*'#') + (22 - i*2) * ' ' + (i*'#')

hourglass(0,10,1)
hourglass(10,0,-1)


Reflection : Managed to figure out how the pattern of the code should be after 10 minutes of screwing around with the codes.
I'm bad with visualizing such stuffs in my mind with program codes, hope next time don't have such troublesome question lol.


Thursday, 14th June 2012

Today programming lesson
Tio scam
Not ball, but is a moving stick
Teacher tell me is a running man, what shitty graphics is that lol


Gao~

Managed to finish today de programming target cause got help from other programmers
Hate visualizing weird things =.=


Reflection Journal also need write about codes LOL

After programming lesson, went for 2nd UT
Which is Communication Practice

Kinda easy actually, at least easier than Creative Concepts lol
At least no need think about durian and batman~

Wednesday, June 13, 2012

Wednesday, 13th June 2012

Slept at 12.30 last night, today woke up quite tired x.x
Was deep in thoughts this morning, thinking how to stop my cat escaping the house through my window.
Father thought I having troubles, asked me why am I so quiet lol

Sian, today Creative Concept need to act out
It's for overcoming stage fright

But I don't have stage fright, I have act fright x.x

Muffin came my house after school, to make notes and also study for tomorrow's UT
After we made notes for Communication Practice, I sent her back to Clementi
We went to eat Pepper Lunch and also Ice Kacang.

She ordered beef pepper lunch while I ordered the salmon one ~.~
The Ice Kacang sucks seriously lol, wonder the red bean low quality or what


Hope tomorrow can finish UT on time x.x

Tuesday, June 12, 2012

Tuesday, 12th June 2012

Reached school early & suffered in science terribly cause is chemistry topic -_-
Not gonna elaborate much about it.


Managed to do my Creative Concept UT without much difficulties, I liked the Durian & Batman part lol.
UT ended around 5.30, still got another one on Thursday x.x


Went to eat Mac Donalds with Muffin at Admiralty, also purchased a new shampoo & toothpaste.
The new shampoo states with conditioner, seems to work o.o
Can feel my hair smoother now, hope the effects last lol



Asked programming 06 problem statement from Sotong, mindfu3ked by it



Gonna die on Thursday le x.x

Monday, June 11, 2012

Monday, 11th June 2012

Woke at 5 am, unable to sleep x.x
School finally starting soon, feeling slightly uneasy (not sure why)

Reached school on 8 am, kinda early
Wonder today do what, hope I won't fall asleep ~.~

Today need do about perspective of story, my group decided on Snow White.
Need to re-write Snow White story from the view of step mother/witch.

Managed to survive today, got along with my team mates cause of random chit chat.
Talk with guys about anime stuffs, while talk with girls about bullies in school.
Today briefly taught Muffin abit of programming, also went to eat Okonomiyaki with her.
Reached home at 9, also tio bus sick from 858 -_-

Sunday, June 10, 2012

Sunday, 10th June 2012

Slept at 8 am, woke at 3 pm.


Nothing to do & tomorrow starts school le x.x
I don't mind going school, I just hate how Art of Story already gave me 3 C for 5 lessons =.=



Wanted to go find Muffin this evening, uncle suddenly came to visit.
So my father bring us go eat at a seafood restaurant

- Lobster porridge
- Fried egg with prawns
- Fried chicken
- Random vegetables

Then uncle asked me pei him walk Chong Pang to see durians, mini ones (50 cents each)

In the end buy until 16, my father took home 8.

Durians x.x

Saturday, June 9, 2012

Saturday, 09th June 2012

Woke up at near 5 pm today, nothing to do x.x

Went out to buy a new nokia phone (C1), of course black color phone
Also bought a memory card for it, price seems reasonable.
4 GB memory for $10





















Ate plain Double Cheese Burger Meal upsized
Wonder what to do next x.x

Got Shaolin Soccer English Subbed, just in case Muffin wanna watch it.

Installed Wanko to Kurasou for fun, maybe next time replay x.x

Friday, June 8, 2012

Friday, 08th June 2012

Slept at 5 am last night, I also forgot what I did.
Woke at 11 am cause pei Muffin go RP today

She gonna study for her science while I do nothing & slack


Slacked at school until 4 pm, then went to my aunt house
Think I too blur today, forgot teach her the buffet question of programming lolz

Ate together at my aunt house

- Egg
- Salmon
- Random vegetables with prawns in it

Sent Muffin to Admiralty MRT then I went back to Yishun

Bought 10 lolipops for $1, & also an emergency charger just in case my PSP or handphone runs out of battery when I'm outside.
The charger needs 2 AA batteries, that's okay with me o.o

School gonna reopen soon x.x


Just managed to get John Carter HD & Jurassic Park Trilogy ~.~

Thursday, June 7, 2012

Zoo Fare.py

Went to check my Zoo Fare.py file, realized got some flaws in my way of coding

Old Code :

adult = int(raw_input("Please key in the amount of adults : "))
children = int(raw_input("Please key in the amount of children : "))
eldery = int(raw_input("Please key in the amount of senior citizens : "))
location = raw_input("Choose Zoo or Zoo and Night Safari (ZOO/ZNS): ")
upgrade = raw_input("Upgrade to Zoo-per Saver Pass (Y/N): ")


def TotalCost(adult_ticket, child_ticket, eldery_ticket) :
    totalfare = (adult * adult_ticket) + (children * child_ticket) + (eldery * eldery_ticket)

    if (upgrade == "y" or upgrade == "yes") :
        totalprice = (adult * 7) + (children * 4) + (eldery * 7) + totalfare
        print "The total cost would be $" + str(totalprice)
        print "Would you like some fries with that?"


    elif (upgrade == "n" or upgrade == "no") :
        print "The total cost would be $" + str(totalfare)
        print "Would you like some fries with that?"


if (location == "zoo") :
        TotalCost(20,13,10)


elif (location == "zns") :
        TotalCost(42,28,26)


New Code :

adult = raw_input("Please key in the amount of adults : ")
children = raw_input("Please key in the amount of children : ")
eldery = raw_input("Please key in the amount of senior citizens : ")
location = raw_input("Choose Zoo or Zoo and Night Safari (ZOO/ZNS): ")
upgrade = raw_input("Upgrade to Zoo-per Saver Pass (Y/N): ")


try:
    adult = int(adult)
    if adult < 0:
        print "Please enter value equal or more than 0 for adults"
        exit()


    children = int(children)
    if children < 0:
        print "Please enter value equal or more than 0 for children"
        exit()


    eldery = int(eldery)
    if eldery < 0:
        print "Please enter value equal or more than 0 for eldery"
        exit()


except ValueError:
    print "Please key in the amount of people in numbers"

    exit()
upgrade = upgrade.lower()
location = location.lower()


def TotalCost(adult_ticket, child_ticket, eldery_ticket) :
    totalfare = (adult * adult_ticket) + (children * child_ticket) + (eldery * eldery_ticket)

    if (upgrade == "y" or upgrade == "yes") :
        totalprice = (adult * 7) + (children * 4) + (eldery * 7) + totalfare
        print "The total cost would be $" + `totalprice`       


    elif (upgrade == "n" or upgrade == "no") :
        print "The total cost would be $" + `totalfare`       


    else :
        print 'Please key in either Yes(Y) or No(N) for the Upgrade'


if (location == "zoo") :
        TotalCost(20,13,10)


elif (location == "zns") :
        TotalCost(42,28,26)


else :
        print 'Please key in either Zoo or Zns'


What changes has been made :
- Able to determine whether the number of people keyed in are integers, instead of strings or other weird variables
- Able to accept strings for condition upgrade == 'n' or upgrade == 'no' regardless of upper or lower case, example would be like 'nO', 'NO'.
- Display error message if the user keyed in wrong answer in any string statement.
- Found alternative to cast interger into string by typing `x` instead of the standard casting str(x)
- Fixed logical error of negative values input, resulting lesser money count or even negative results

Conclusion :
Although I'm able to detect errors & prevent my program from crashing due to unknown values being entered, my codes will become longer.
No choice but to learn this as teacher will expect our codes have no errors at all in future, just face it lol


Amount of code lines jumped from 21 to 50 lol