Answer to Question #98722 in Python for yousif

Question #98722
Write a program that creates an array called temperatures and then add five temperatures input from the keyboard.

Print the array.

Sample Run:

Enter a temperature: 45
Enter a temperature: 67
Enter a temperature: 89
Enter a temperature: 47
Enter a temperature: 89
[45, 67, 89, 47, 89]
1
Expert's answer
2019-11-15T10:43:43-0500
temperatures = []
i = 0
while i < 5:
    try:
        t = int(input('Enter a temperature: '))
        temperatures.append(t)
        i += 1
    except ValueError:
        print('Enter a number')
print(temperatures)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS