-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfuncoes.py
More file actions
55 lines (42 loc) · 1.32 KB
/
funcoes.py
File metadata and controls
55 lines (42 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on 21 de jul de 2018
@author: Ryan Gazaniga <ryangazaniga@gmail.com>
"""
"""
Classe Demo
"""
class myFormula:
def __init__(self):
pass
def __celsius_to_kelvin(self, c):
c = float(c)
result = c + 273
return result
def __kelvin_to_celsius(self, k):
k = float(k)
result = k - 273
return result
def __celsius_to_fahrenheit(self,c):
c = float(c)
result = 1.8 * c + 32
return result
def __fahrenheit_to_celsius(self,f):
f = float(f)
result = (f - 32) * 5/9
return result
def TemperaturaGetEnum(self):
unity = ["Celsius", "Fahrenheit", "Kelvin"]
varis = ["Temperatura:"]
Enum = "Conversor de temperatura\nEntre com o valor da temperatura e selecione a unidade:"
return varis, Enum, unity
def Temperatura(self, temp, unity):
temp = float(temp)
if unity == "Celsius":
f = self.__celsius_to_fahrenheit(temp)
k = self.__celsius_to_kelvin(temp)
strshow = "%.2f o Celsius\n%.2f o Fahrenheit\n%.2f o Kelvin" % (temp, f, k)
return strshow, temp
#TODO: implement unity == "Fahrenheit" and "Kelvin"
strshow = "case not implemented"
return strshow, 0