143k views
3 votes
Lists and arrays can be valuable tools for the programmer. 1. provide an example of a ‘list' and explain how it would be used as part of a problem solution. 2. provide an example of an array and explain how it would be used as part of a problem solution.

User Yona
by
8.5k points

1 Answer

1 vote
#Get the user input for both MPG and Gallons
MPG = float(input('How many miles have you driven?'))
Gallons = float(input('How many gallons are in the tank?'))
#Do the MPG divided by Gallons
MPG_div_Gallons = MPG/Gallons
print('Your cars MPG is ',MPG_div_Gallons,'.')
#to hold the code I am using an input
input('Press Enter to Exit')
The arrays are "MPG", MPG_div_Gallons,and Gallons. It can be used to solve an average of mile per gallon has been emission in a certain amount of drive. (Code in Python)
User Zuoanqh
by
8.3k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories