Kruptein 15 Posting Whiz in Training

I would instead of using seperate variables for the different materials, use a dictionary

#-*- coding: cp1252 -*-
substances = {
'aluminium':0.000023,
'concrete':0.000012,
'silver':0.000019,
'gold':0.000014,
'copper':0.000017,
'glass':0.000008,
}

a = raw_input("enter substance: ")
l = float(raw_input("give original length: "))
t = float(raw_input("how much the temperature changes: "))

answer = substances[a]*l*t
print answer

be aware that it will be case sensitive and Aluminium won't be recognised whereas aluminium is

vegaseat commented: helpful +15
Kruptein 15 Posting Whiz in Training

the correct statement is:

SELECT a, b, sum(a + b) from table1

sum is an existing method that returns the sum of the passed items

Kruptein 15 Posting Whiz in Training
#!/usr/bin/python
def sums(n):
    total = 0
    next_odd=1
    while next_odd <= n:
        total += next_odd
        next_odd+=2
    return total
 
 
 
def main():
    n = input('Enter a number: ')
    s = sums(n)
    print 'The sum of the numbers is', s
    while n <= 0:
        print "Please Enter a positive number."
        break
 
 
 
main()
Kruptein 15 Posting Whiz in Training

But like your code, if I don't search for a word that is in the list, it gives ne an index error. That's not converting anything, just spitting out the same word. I was thinking like the integer 10 to "ten"

Okay if U give a number in words larger then nine it will throw an error,
but I just used the same example as the topic starter.

the thing you ask is the reverse, if U want that you have to do:

def numtoword(num):
    wordlist=["zero","one","two","three","four","five","six","seven","eight","nine"]
    if int(num)>len(wordlist):
        print "sorry that number is not in the list"
    else:
        return wordlist[int(num)]
Kruptein 15 Posting Whiz in Training

So what is the program supposed to do? Are you supposed to input a number and get the word form of the number? Or input the word and get the integer it represents?
And incase you didn't know the code tags they are [COD'E] [/COD'E] with out the ' in them.

this is code......

I think he means that you have to pass a word and convert it in an integer.

just like my code does ...

Kruptein 15 Posting Whiz in Training

camigirl4k3,
you got to learn to use the necessary indentations with your statement blocks.

The indentations are maybe changed because camigirl4k3 doesn't use code tags

Kruptein 15 Posting Whiz in Training

In your case it's actually much easier to use:

def wordtonum(word):
    wordList = ["zero","one","two","three","four","five","six","seven","eight","nine"]
    return int(wordList.index(word))
Kruptein 15 Posting Whiz in Training

if digit is in string form: digit[:1] if the digit is an integer: str(digit)[:1] *or even easier: str(digit)[0]

Kruptein 15 Posting Whiz in Training

Ah now I got it =D, yes with javascript it should be possible

Kruptein 15 Posting Whiz in Training

First: this is not php but html and css
second: you can just use div's in div's

<div style='...'>
    <div style='...'>
    </div>
    <div name='a'>
    </div>
</div>
Kruptein 15 Posting Whiz in Training

You used an inner join after the where clause..

Kruptein 15 Posting Whiz in Training

First: What is the error you get
Second: why are you using different indents?
this is a) very ugly and b) will give errors

Kruptein 15 Posting Whiz in Training

You have to do:

echo '<form method ="get" action = "tele.php">
	          Phone:
	   		  <input type = "text" name ="number" value= "">
                        <input type="text" name="fname" value="' . $tesing . '">
	   		<br>';
Kruptein 15 Posting Whiz in Training

You can simply do this with php, and include some ajax to make everything easier for the user, I don't know anything about ajax :p
with php you will have to make a html form like this:

<form action='example.php' method='post'>//or an other page or get
<input type='text' name='txt'></form>

example.php
Here you will need to do some queries to get a product from the database and show it to the user.

Kruptein 15 Posting Whiz in Training

I had once the same problem, in FF everything was messed up. I've solved it by instead of using: width: 150px doing width: 145px
Try to do some pixels of the width, heigth and say if it still occurs.

Kruptein 15 Posting Whiz in Training

in one query:

UPDATE table SET field3 = field1-field2

I think this should work.

(everytime you update/change a value of field1/field2 you will have to do this query, mysql can't do this automatic..)