-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.py
More file actions
40 lines (32 loc) · 766 Bytes
/
function.py
File metadata and controls
40 lines (32 loc) · 766 Bytes
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
# computes the area of triangle
def triangle_area(base, height):
area = (1.0/2) * base * height
return area
#test
a1 = triangle_area(3, 8)
print a1
a2 = triangle_area(14, 2)
print a2
# converts fahrenheit to celsius
def fahrenheit2celsius(fahrenheit):
celsius = (5.0/9) * (fahrenheit - 32)
return celsius
#test
c1 = fahrenheit2celsius(22)
c2 = fahrenheit2celsius(212)
print c1, c2
# converts fahrenheit to kelvin
def fahrenheit2kelvin(fahrenheit):
celsius = fahrenheit2celsius(fahrenheit)
kelvin = celsius + 273.15
return kelvin
#test
k1 = fahrenheit2kelvin(32)
k2 = fahrenheit2kelvin(213)
print k1, k2
# print hello, world!
def hello():
print "hello, world!"
#test
h = hello()
print h