代写python Time Series作业、代写python ai作业、代写python 程序作业


# Uses Global Temperature Time Series, avalaible at
# assumed to be stored in the working directory.
# Prompts the user for the source, a year or a range of years, and a month.
# - The source is either GCAG or GISTEMP.
# - The range of years is of the form xxxx -- xxxx (with any number of spaces,
# possibly none, around --) and both years can be the same,
# or the first year can be anterior to the second year,
# or the first year can be posterior to the first year.
# We assume that the input is correct and the data for the requested month
# exist for all years in the requested range.
# Then outputs:
# - The average of the values for that source, for this month, for those years.
# - The list of years (in increasing order) for which the value is larger than that average.
#
# Written by *** and Eric Martin for COMP9021


import sys
import os
import csv


filename = 'monthly_csv.csv'
if not os.path.exists(filename):
print(f'There is no file named {filename} in the working directory, giving up...')
sys.exit()

source = input('Enter the source (GCAG or GISTEMP): ')
year_or_range_of_years = input('Enter a year or a range of years in the form XXXX -- XXXX: ')
month = input('Enter a month: ')
average = 0
years_above_average = []

# REPLACE THIS COMMENT WITH YOUR CODE

print(f'The average anomaly for {month} in this range of years is: {average:.2f}.')
print('The list of years when the temperature anomaly was above average is:')
print(years_above_average)

QUIZ 3
COMP9021 PRINCIPLES OF PROGRAMMING
Sample outputs
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GISTEMP
Enter a year or a range of years in the form XXXX -- XXXX: 1983--1958
Enter a month: January
The average anomaly for January in this range of years is: 0.07.
The list of years when the temperature anomaly was above average is:
[1958, 1961, 1962, 1970, 1973, 1975, 1977, 1978, 1979, 1980, 1981, 1982, 1983]
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GCAG
Enter a year or a range of years in the form XXXX -- XXXX: 1890 -- 1901
Enter a month: December
The average anomaly for December in this range of years is: -0.16.
The list of years when the temperature anomaly was above average is:
[1891, 1895, 1896, 1898, 1900]
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GISTEMP
Enter a year or a range of years in the form XXXX -- XXXX: 1983 -- 1958
Enter a month: May
The average anomaly for May in this range of years is: 0.05.
The list of years when the temperature anomaly was above average is:
[1958, 1959, 1961, 1967, 1969, 1973, 1975, 1977, 1978, 1979, 1980, 1981, 1982, 1983]
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GCAG
Enter a year or a range of years in the form XXXX -- XXXX: 1958--1983
Enter a month: May
The average anomaly for May in this range of years is: 0.07.
The list of years when the temperature anomaly was above average is:
[1958, 1961, 1967, 1969, 1973, 1977, 1979, 1980, 1981, 1982, 1983]
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GISTEMP
Enter a year or a range of years in the form XXXX -- XXXX: 2016 -- 2016
Enter a month: June
The average anomaly for June in this range of years is: 0.76.
The list of years when the temperature anomaly was above average is:
[]
$ python quiz_3.py
Enter the source (GCAG or GISTEMP): GCAG
Enter a year or a range of years in the form XXXX -- XXXX: 1945
Enter a month: September
The average anomaly for September in this range of years is: 0.26.
The list of years when the temperature anomaly was above average is:
[]
Date: Session 2, 2018.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/pythoncoding/p/9498257.html