473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

why no result from temprature function

29
Hi
Appreciate any help - why not getting any result from either print statement for celcius of farenheit

Expand|Select|Wrap|Line Numbers
  1. import re
  2. import os
  3. import string
  4. import sys
  5.  
  6. def tempconvert():
  7.     c = ""
  8.     f = "" 
  9.  
  10.     print 'this program converts celcius to farenheit and visa versa'
  11.  
  12.     temp = raw_input ("enter f if you want Faren or c if you want celcius")
  13.     degree = float(raw_input("enter temprature"))
  14.  
  15.     if temp == f:
  16.         c = (degree - 32)* 5/9
  17.         print 'the temprature in celcius is %d'  %c
  18.     elif temp == c:
  19.         f = (9/5 * degree) + 32
  20.         print 'the temprature in farenheit is %d' %f
  21.     else:
  22.         print 'if you see this , good , there is no error'
  23.  
  24. tempconvert()
Thanks
Jan 24 '10 #1
2 1164
bvdet
2,851 Expert Mod 2GB
Please use code tags when posting code. See "How to ask a question" in Posting Guidelines. This is not your first post. You should know this by now.

BV - Moderator
Jan 24 '10 #2
bvdet
2,851 Expert Mod 2GB
Your problem is that you are comparing variable temp to an empty string.

Expand|Select|Wrap|Line Numbers
  1. def tempconvert():
  2.     c = ""
  3.     f = "" 
should be
Expand|Select|Wrap|Line Numbers
  1. def tempconvert():
  2.     c = "c"
  3.     f = "f" 
Jan 24 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Felix | last post by:
Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
4
by: Konrad | last post by:
In the part of code: $polecenie = "SELECT osoby.Id ,osoby.Imie , osoby.Nazwisko,osoby.Tytul,osoby.Email,adrespraca.Adres AS ap, adrespraca.KodPoczt AS...
13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
15
by: John J | last post by:
I've written the following code into a class to search for and display the results of all races entered (The complete code is in a previous thread). I wish to amend the code so as to display the...
2
by: Xiangliang Meng | last post by:
Hi, all. What will we get from sizeof(a class without data members and virtual functions)? For example: class abnormity { public: string name() { return "abnormity"; }
5
by: leo | last post by:
babelfish provides online translation service if clicking one of my links containing: http://babelfish.altavista.com/babelfish/trurl_pagecontent?lp=en_ja&trurl=http://mypage.show.php all the...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
8
rpnew
by: rpnew | last post by:
HI, I'm working with PHP/MySql... on one page i've used this XMLHttprequest object. Now i'm developing the system on FC4/FireFox.. on my machine it works fine but if i try to access it from...
3
by: JRough | last post by:
I want to save two variables in a $_SESSION for use in another page: $_SESSION = $mark; $_SESSION = $num; then on the other page I did this to get the value: $mark =$_SESSION; $num =...
3
by: BOMEz | last post by:
Hi everyone, I have a form which updates some info in a DB. Currently the user does a search, which will load up results, which the user can change, and then submit those changes back into the DB....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.