In: Computer Science
Python programming Summary
Store the times into arrays called Chevy[ ] and Ford[ ]. Then list the winner of each pair, giving the number of seconds the winner won by. At the end declare which team won based on which team had the most wins.
Lab Steps
There are eight cars in each team called Chevy and Ford. One car from each team races its opponent on the drag strip. Read in the racing times for the eight Chevy cars and then read in the times for the eight Ford cars.
Sample Match:
---Input Chevy Times--- |
Specifications:
Code:
chevy=[]
ford=[]
chevyCount=0 #count wins
fordCount=0
print("---Input Chevy times---")
for i in range(8):
print("Enter time for Chevy Car
",i+1,":",end='')
a=float(input())
chevy.append(a)
print("---Input Ford times---")
for i in range(8):
print("Enter time for Ford Car ",i+1,":",end='')
a=float(input())
ford.append(a)
print("And the winners are:")
for i in range(8):
if(chevy[i]>ford[i]):
print("Chevy by
",round(chevy[i]-ford[i],1)," sec") #difference time rounded to 1
decimal
chevyCount=chevyCount+1
elif(ford[i]>chevy[i]):
print("Ford by
",round(ford[i]-chevy[i],1)," sec")
fordCount=fordCount+1
else:
print("Tie!")
if(chevyCount>fordCount): #based on win counts
print("And the winning team is F O R D !")
elif(fordCount>chevyCount):
print("And the winning team is C H E V Y !")
else:
print("T I E !")
Output: