Question

USING PYTHON IDLE 3.4:

Question #8: You want to determine the distance to lightning strikes during a storm. This can be measured using the time elapsed between seeing the lightning flash and hearing the thunder. You know that the speed of sound is approximately 1,100 ft/second and 1 mile is 5,280 feet. Write a program named q8.py that prompts the user for the number of lightning strikes to analyze and the number of seconds between lightning and thunder. For each value entered, the program should calculate and print the distance to the lightning strike in miles. After all the time values are entered and the distances calculated, your program should display the average distance of all the strikes analyzed. Some example output your formatting might not be exactly as shown but should include the following: 2.5 sec 0.5208333333 333334 miles 1.25 sec 0.2604166666666 667 miles 5.4 sec 1.125 miles Total of 3 strikes, average distance of 0.6354166666666666 miles You may use any additional variable names you need, but your program should assign at least the following: number of lightning strikes total sum of all distance calculations average distance of all strikes average dist calculated distance of a single strike

NEED HELP WITH THIS PLEASE! :(

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution: #intialize the list num array = list() #get the number of strikes to be analyzed nra inputcEnter number of ighteni

copyable code:

#intialize the list

num_array = list()

#get the number of strikes to be analyzed

n = raw_input("Enter number of lightening strikes to analyse:")

#gets values of seconds

print 'Enter the seconds: '

for i in range(int(n)):

    #computes the miles travelles based on the given second

    val = ((float(raw_input(" ")))*0.208)

    num_array.append(float(val))

#displays the values after computing

print 'The corresponding miles travelled: ',num_array

#calculates the average

total = 0

for elm in num_array:

     total += elm

avg=total/(len(num_array)*1.0)

print 'The averge miles travelled: ',+ avg

Add a comment
Know the answer?
Add Answer to:
USING PYTHON IDLE 3.4: NEED HELP WITH THIS PLEASE! :( Question #8: You want to determine...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program using python that determines the distance to a lightning strike based on the...

    Write a program using python that determines the distance to a lightning strike based on the time elapsed between the flash and the sound of thunder. The speed of sound is approximately 1120 ft/sec and 1 mile is 5280 ft. You need to use a function for this program. It needs to take a single argument and return a single value.

  • Can you help me write a Python 3.7 code for this question? Write a program using...

    Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...

  • Need help Purpose Calculate mileage reimbursements using arrays and methods. The Mathematical Association of America hosts...

    Need help Purpose Calculate mileage reimbursements using arrays and methods. The Mathematical Association of America hosts an annual summer meeting. Each state sends one official delegate to the section officers’ meeting at this summer session. The national organization reimburses the official state delegates according to the scale below. Write a Java program to calculate the reimbursement values, satisfying the specifications below. Details on array and method usage follow these specs. 1. The main method should declare all the variables at...

  • Python 3 Problem: I hope you can help with this please answer the problem using python...

    Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks! Code the program below . The program must contain and use a main function that is called inside of: If __name__ == “__main__”: Create the abstract base class Vehicle with the following attributes: Variables Methods Manufacturer Model Wheels TypeOfVehicle Seats printDetails() - ABC checkInfo(**kwargs) The methods with ABC next to them should be abstracted and overloaded in the child class Create three...

  • Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Probl...

    Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Problem statement: Business trip is part of the enterprise culture. Suppose a businessperson just completed a business trip for your company. Now, you are tasked to write a program that calculates and displays the total travel expenses, allowable expenses for the trip, and the excess that must be paid by the businessperson, if any The program should prompt the user for the following . The...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT