Question: Write a Python program that implements a Metar class containing a special method that allows you to print out the text of an undecoded METAR
Write a Python program that implements a Metar class containing a special method that allows you to print out the text of an undecoded METAR and a tmpf method that computes the temperature in Fahrenheit from the METAR. Use the remark that provides data to the nearest tenth of a degree Celsius if available; otherwise, the temperature in the body of the METAR will suffice. The temperature should be rounded to the nearest integer. Use the following code below as a starting point
class Metar:
# Your code here!
# Do not modify code after this line! --------------------
METARs = ['KLAR 251542Z AUTO 33010KT 1/4SM +SN FZFG VV008 M03/M05 A3014 RMK' \
' AO2 P0002 T10331050', \
'KOKC 252347Z 35036G49KT 1 1/4SM R35R/5000VP6000FT +TSRA BKN008CB' \
' OVC031 16/13 A2967 RMK AO2 PK WND 30051/2333 WSHFT 2330' \
' TSB15RAB33GRB35E43 CONS LTGICCCCACG OHD TS OHD MOV E', \
'KEWR 252351Z 14003KT 5SM -RA BR BKN020 BKN029 OVC045 04/02 A3025' \
' RMK AO2 SLP243 P0002 60005 T00390017 10072 20039 55012', \
'KINL 252346Z AUTO 30014G23KT 1/2SM -SN FZFG BKN008 OVC013 M01/M02' \
' A2981']
for m in METARs: ob = Metar(m)
print ob tf = ob.tmpf()
print 'The temperature is: %iF' % tf
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
