-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_3.py
More file actions
57 lines (39 loc) · 1.03 KB
/
05_3.py
File metadata and controls
57 lines (39 loc) · 1.03 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
56
57
'''
Haris Khan
Area of a circle
'''
import math
radius = int(input("Enter the radius:"))
area = math.pi * pow(radius, radius)
print("Area of circle: ", area)
'''
Frequency of a word in a string
'''
string = input("Enter a string of words: ")
str_ = string.split(' ') #list of stringed words
words = {}
try:
for i in str_:
if i in words:
words[i] += 1
else:
words[i] = 1
except ValueError as e:
print(e)
for w, i in words.items():
print(f'Frequent Word: {w}, Count: {i}')
'''
Temperature Converter from Celsius to Fahrenheit
'''
def temp_choice():
unit = input("Choose which unit of temp conversion:")
tmp = int(input("Temp: "))
if unit == "Celsius" or unit == "C":
print("Converting from Fahrenheit to Celsius")
form = (tmp * 9/5) + 32
else:
print("Converting to Fahrenheit from Celsius")
form = ((tmp) - 32) * 5/9
return form
if __name__ == "__main__":
print(temp_choice())