Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

python - how can I make it where it shows the average temperature

def main():
    #temperature data for Aurora:
    highTemps = [-3, -2, 3, 11, 19, 23, 26, 25, 20, 13, 6, 0]
    lowTemps = [-11, -10, -5, 1, 8, 13, 16, 15, 11, 5, -1, -7]
    weatherDB = createDB(highTemps, lowTemps)  #do not change this line

   

    for m in weatherDB: 
        for t in weatherDB[m]: 
            print(m, t, weatherDB[m][t])

    m = input("Enter a Month Name: ")
    if m in weatherDB: 
      print(weatherDB[m])
    else: 
      print("Month not found")



    
    #Toronto:
    torontoDB = createDB([0, 0, 5, 12, 19, 24, 27, 26, 23, 15, 9, 3],
                         [-7, -7, -2, 4, 10, 15, 18, 18, 14, 8, 2, -3])
    #New York City:
    nycDB = createDB([4, 6, 11, 18, 22, 27, 29, 29, 25, 18, 13, 7],
                     [-3, -2, 2, 7, 12, 18, 20, 20, 16, 10, 6, 0])

    #Los Angeles:
    laDB = createDB([20, 21, 21, 23, 24, 26, 29, 29, 29, 26, 23, 20],
                [10, 10, 11, 13, 15, 17, 18, 19, 18, 16, 12, 9])

    #Tokyo:
    tokyoDB = createDB([10, 10, 14, 19, 23, 26, 30, 31, 27, 22, 17, 12],
                       [2, 2, 5, 10, 15, 19, 23, 24, 20, 15, 9, 4])


def averageHighTemps(weatherDB, higherTemps, lowTemps):
    for m in createDB: 
        for t in higherTemps[m]: 
            print(m, t, createDB[m][t])

    m = input("Enter a Month Name: ")
    if m in weatherDB: 
      print(weatherDB[m])
    else: 
      print("Month not found")
    return

basically, I need it to say when it prints the average temperature between the high temp and the low temp and I have no idea how to do that and make it when it prints the temperature its simple and doesn't have the {} brackets

question from:https://stackoverflow.com/questions/65833866/how-can-i-make-it-where-it-shows-the-average-temperature

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...