Python 3.4摄氏度到华氏度

时间:2016-02-26 06:11:24

标签: python python-3.4

我在python 3.4中需要一个USER INPUT代码,将Celsius变为Fahrenheit。用户输入摄氏温度并变为神经学位的地方。

3 个答案:

答案 0 :(得分:0)

您需要输入一个输入语句:

celsius = input("Enter degrees in Celsius')

然后编写用于将摄氏度转换为华氏度的代码:

Celsius -> Fahrenheit:

Multiply by 9, then Divide by 5, then Add 32

答案 1 :(得分:0)

# Name
Name = raw_input("Enter name= ")

# Enter fDegree value
F = input("enter Fah Degree value= ")

# Calculation for cDegree
C = (5.00/9.00)*(F-32.00)`#formula`

print "The input Fdegress= {:.2f}".format(F)
print "Celsius Degree = {:.2f}".format(C)

答案 2 :(得分:0)

您好,此程序可以同时计算华氏度到摄氏温度和摄氏温度到华氏温度。如果向下滚动,您将看到摄氏本身的代码。

$(function() {var iframeOffset = $("#gramps", window.parent.document).offset();
  $("a").each(function () {
    var link = $(this);
    var href = link.attr("href");
    if (href && href[0] == "#") {
      var name = href.substring(1)
      $(this).click(function () {
          var nameElement = $("[name='" + name + "']");
          var idElement = $("#" + name);
          var element = null;
          if (nameElement.length > 0) {
             element = nameElement;
          } else if (idElement.length > 0) {
             element = idElement;
          }
           if (element) {
             var offset = element.offset();
              window.parent.scrollTo(offset.left, offset.top + iframeOffset.top);
           }
           return false;
       });
      }
   });
});

摄氏本身的代码:

import time # importing functions 
start=time.perf_counter()#starting timer 
try:
    x=int(input(' 1-Fahrenheit to Celsius. 2-Celsius to Fahrenheit please enter option 
1 or 2:')) #asking for input 
    if x==1:
        a=int(input('enter the temperature in Fahrenheit')) # asking the temperature
        b=(a-32)/1.8# calculating
        print('the temperature is',b,'degrees celsius')#printing 
     elif x==2:
        c=int(input('enter the temperature in celsius'))
        d=(c*9/5)+32
        print('the temperature is ' ,d,'degrees Fahrenheit')
    else:
        print('please enter a valid option')
except Exception:
    print('please enter something valid')#error statement 
finally:
    end=time.perf_counter()#ending timer
    f=end-start
message='The time taken is %s seconds'
print(message % f)# printing time 

如有任何疑问,请告诉我 Anikait Sota