Friday, June 22, 2012

Last Question in Programming UT 1


def my7(a,b):

    total = a+b

    if (a > b):
        diff = a - b
    else:
        diff = b - a

    if (a == 7 or b == 7):
        return True
    elif (total == 7 or diff == 7):
        return True
    else:
        return False

Friday, 22th June 2012

Today Communication Practice
Need go down for a talk, by Mr Sam Tan

Discussed about how communication barrier can be formed by 4 type of noises
- Physical
- Psychological
- Physiological
- Semantic

Afterwards, went for programming UT
So hard sia lol

Guessing Game

Made this game with the help of 6P and prior knowledge from ITE de C# programming

Just a simple guessing game in Python that only requires user to guess a digit from 1 to 99 by just entering the answer they feel is right

The code :

import random

ans = random.randint(1,99)
low = 1
high = 99
temp_low = 0
temp_high = 0
guess = ' '
tries = 1

while (guess != ans):
    tries = tries + 1
    guess = raw_input("Guess the number between 1 and 99: ")

    try:
        guess = int(guess)
        if guess < 1 or guess > 99:
            print "Please enter between 1 to 99"
            exit()

    except:
        print "Invalid Entry, Game Over"
        exit()

    if guess < ans:
        if guess > low:
            temp_low = guess

        low = guess

        if low > temp_low:
            low = low

        else:
            low = temp_low
        print "You entered " + `guess`
        print "It is HIGHER than " + `low` + " but LOWER than " + `high`

    elif guess > ans:
        if guess < high:
                temp_high = guess

        high = guess

        if high < temp_high:
            high = high

        else:
            high = temp_high
        print "You entered " + `guess`
        print "It is HIGHER than " + `low` + " but LOWER than " + `high`

print "Well done!"
print "The answer is "+ `ans` + "!"
print "You took " + `tries` + " tries"

if tries <= 5:
    print "Wow, you're really lucky"
if tries > 5 and tries <= 10:
    print "Not bad, quite lucky~"
else:
    print "Nice effort, you might be luckier on next game!"


Gonna try create Scissor, Paper, Stone game with a similar concept when free

Thursday, June 21, 2012

Worksheet [List]

# Lucky Number

name = raw_input("Enter your full name")

def calculateLuckyNumber(name):
    nameSplit = name.split(' ')
    F = len(nameSplit[0])
    S = len(nameSplit[1])
    T = len(nameSplit[2])
    luckyNum = ((2 * F + S) + T) % 10
    return luckyNum

print calculateLuckyNumber(name)

# Using List

sentence = "Dell profit surges on revived business spend"
words = sentence.split()

print words[0] + " " + words[4] + " " + words[5]
print len(words[0]) + len(words[4]) + len(words[5])

#Filtering Words

sentence = 'cat dog lion tiger mouse cow'
sentenceSplit = sentence.split(' ')

for a in range(0,6,1):
    count = len(sentenceSplit[a])
    if count == 3:
        print sentenceSplit[a]

# Sum Up Numbers

num_list = range(0,30,4)
total = 0
for a in num_list:
    total = total + a
print total

# Sum Up Even Numbers

num_list = range(0,30,3)
total = 0
for x in num_list:
    if x % 2 == 0:
        total+=x
print total

# Count even numbers
num_list = range(0,30,3)

even = 0
for x in num_list:
    if x % 2 == 0:
        even+=1
print even

Thursday, 21th June 2012

Today do programming

I know how to do, but don't know how to explain lol
Need make a program called Fortune Teller / Lucky Lucky
Take in the user's name and day, calculate lucky number & color

Wednesday, June 20, 2012

Wednesday, 20th June 2012

Today Creative Concepts
Need design a float for Chingay festival
Theme is Garden City

I never go to Chingay before, so I don't know what is it lol
Just playing along with it
Need artist for this mission lol

Made a few China quality buildings with paper and others with recycled stuffs.

Both me & Muffin feeling abit sick today
I recovered after drinking cold water & hyper for nothing
But she still sick, hope she recover soon x.x

Blackthorn Morgana

Tuesday, June 19, 2012

Practice of coding during UT clinic [ Electronegativity values difference between elements ]

The UT clinic was unhelpful to a large extent, so I practice programming on my own without any references.

a = raw_input("Please enter the 1st Electronegativity")
b = raw_input("Please enter the 2nd Electronegativity")

try:
    a = float(a)
    if a < 0:
        print "Invalid value"
        exit()

    b = float(b)
    if b < 0:
        print "Invalid value"
        exit()

except:
    print "Please enter valid float"
    exit()

if a > b:
    c = a - b
elif b > a:
    c = b - a

if c < 0.5:
    print "Difference is " + `round(c,2)`
    print "It is Non-Polar Covalent Bond"
    print "Temporary Charges"

if c > 0.5 and c < 2.0:
    print "Difference is " + `round(c,2)`
    print "It is Polar Covalent Bond"
    print "Permanent Charges"

if c > 2.0:
    print "Difference is " + `round(c,2)`
    print "It is Ionic Bond"
    print "Permanent Charges"

Electronegativity and Types of bonds

When two atoms share electrons, a covalent bond is formed.
i.    If electrons are shared more or less equally, a non-polar covalent bond exists between the atoms (e.g. H-C).

ii.    If electrons are shared unequally, a polar covalent bond exists between the atoms (e.g. H-O).













Values of the elements


Tuesday, 19th June 2012

Slept at 10 pm last night
Today woke at 7 am to buy Egg McMuffin for Muffin

Today need study the chemical properties of water
Example:
- Why does ice cube float on water
- Why is water able to dissolve various substances like salt
- Why water has a high boiling point

Notes :
Hydrogen Bonding can only occur when H is interacting with F, N or O

To determine the polar, non-polar or ionic bond.
Need calculate the difference between the elements de elctronegativity values.