Question

Programming With the List of Elevations, Latitudes, & Longitudes Pseudocode Using CodeHS Sandbox, write a program...

Programming With the List of Elevations, Latitudes, & Longitudes Pseudocode

Using CodeHS Sandbox, write a program using the following guidelines:

  • Program should have comments at the top with: program name, student name, date, and description of what the program does.
  • Write a program that uses three separate functions: elevation_range, ave_position, and max_change.

    elevation_range will accept the elevation list as a parameter and find the range of elevation by finding the max elevation and min elevation and returning the difference (range = max - min)

    ave_position should accept the latitude list and longitude list as parameters and find the average position of all the schools by finding the average latitude and average longitude and then print the average position

    max_change will accept the elevation list as a parameter and will determine the positive difference in elevations between adjacent schools in the list, and return the greatest difference in elevations between adjacent schools.

Note: Each of these functions must use a loop to traverse through the list to receive full credit.

  • A main method which calls the three functions elevation_range, ave_position, and max_change and prints the returned values.
  • A call to the main method
  • Run the program several times to make sure it is working properly
  • After you are sure the program is running correctly, create a "screen recording" in which you explain the code you have written and demonstrate that your program works properly for the three methods.
  • Submit both the url of your saved CodeHS program with the screen recording of your output

EXAMPLE TEMPLATE

# Program template for "Programming with Lists of Elevations,

# Latitudes, and Longitudes".

# elevation_range will accept the elevation list as a parameter

# and find the range of elevation by finding the max elevation

# and min elevation and returning the difference (range = max - min)

def elevation_range(elev_list):

    # put code here

    

    

# ave_position should accept the latitude list and longitude list

# as parameters and find the average position of all the schools

# by finding the average latitude and average longitude and then

# print the average position

def ave_position(lat_list, long_list):

    # put code here

    

    

# max_change will accept the elevation list as a parameter and

# will determine the positive difference in elevations between

# adjacent schools in the list, and return the greatest difference

# in elevations between adjacent schools.

def max_change(elev_list):

    # put code here

    

# define the main method

def main():

    elev_list = [17.0, 76.8, 120.0, 1619.1, 182.0, 159.0, 252.0, 294.0, 31.7, 8.0, 8.5, 39.3, 144.0, 798.0]

    lat_list = [30.0, 47.7, 47.7, 35.1, 32.9, 38.2, 33.8, 34.8, 28.6, 32.0, 25.7, 39.4, 40.0, 31.7]

    long_list = [-22.6, -122.3, -122.3, -106.6, -96.8, -85.7, -84.4, -82.4, -81.4, -81.1, -80.3, -76.6, -75.4, 35.8]

    

    # call and print results of elevation_range

    range = elevation_range(elev_list)

    print "The range of the elevation data is: " + str(range)

    print " "

    

    # call ave_position which will print the average latitude and longitude

    ave_position(lat_list, long_list)

    print " "

    

    # call and print results of max_change

    max_c = max_change(elev_list)

    print "The maximum change between adjacent schools is: " + str(max_c)

    

# call the main method

main()

NEED HELP BASIC PYTHON COMPUTER SCIENCE

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

MODIFIED CODE:

# Program template for "Programming with Lists of Elevations,

# Latitudes, and Longitudes".

# elevation_range will accept the elevation list as a parameter

# and find the range of elevation by finding the max elevation

# and min elevation and returning the difference (range = max - min)

def elevation_range(elev_list):

# put code here
m=elev_list[0]
mi=elev_list[0]
for i in elev_list:
if i>m:
m=i
for i in elev_list:
if i<mi:
mi=i
return m-mi

# ave_position should accept the latitude list and longitude list

# as parameters and find the average position of all the schools

# by finding the average latitude and average longitude and then

# print the average position

def ave_position(lat_list, long_list):
# put code here
suma1=0
suma2=0
for i in lat_list:
suma1+=i
for i in long_list:
suma2+=i
a1=(suma1)/len(lat_list)
a2=(suma2)/len(long_list)
print((a1+a2)/2)

# max_change will accept the elevation list as a parameter and

# will determine the positive difference in elevations between

# adjacent schools in the list, and return the greatest difference

# in elevations between adjacent schools.

def max_change(elev_list):
# put code here
l=[]
for i in range(len(elev_list)-1):
l.append(elev_list[i+1]-elev_list[i])
return max(elev_list)
  
# define the main method

def main():

elev_list = [17.0, 76.8, 120.0, 1619.1, 182.0, 159.0, 252.0, 294.0, 31.7, 8.0, 8.5, 39.3, 144.0, 798.0]

lat_list = [30.0, 47.7, 47.7, 35.1, 32.9, 38.2, 33.8, 34.8, 28.6, 32.0, 25.7, 39.4, 40.0, 31.7]

long_list = [-22.6, -122.3, -122.3, -106.6, -96.8, -85.7, -84.4, -82.4, -81.4, -81.1, -80.3, -76.6, -75.4, 35.8]

  

# call and print results of elevation_range

range = elevation_range(elev_list)

print("The range of the elevation data is: " + str(range))

print(" ")

  

# call ave_position which will print the average latitude and longitude

ave_position(lat_list, long_list)

print(" ")

  

# call and print results of max_change

max_c = max_change(elev_list)

print("The maximum change between adjacent schools is: "+ str(max_c))

  

# call the main method

main()

Add a comment
Know the answer?
Add Answer to:
Programming With the List of Elevations, Latitudes, & Longitudes Pseudocode Using CodeHS Sandbox, write a program...
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
  • ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting...

    ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting user's input. Then it prints out the minimum, maximum and average of this array. The framework of testArrav.c has been given like below Sample output: Enter 6 numbers: 11 12 4 90 1-1 Min:-1 Max:90 Average:19.50 #include<stdio.h> // Write the declaration of function processArray int main) I int arrI6]i int min-0,max-0 double avg=0; * Write the statements to get user's input and initialize the...

  • Programming Lab 4 (Chapter 4) There is one checkpoint, make sure you call your professor to...

    Programming Lab 4 (Chapter 4) There is one checkpoint, make sure you call your professor to get checked. 4.1 Write a program that prompts the user for two integers and then prints The sum The difference The product The average The distance (absolute value of the difference) The maximum (the larger of the two) The minimum (the smaller of the two) Hint: The max, min, and absolute value methods are declared in the Math class. Lookup https://docs.oracle.com/javase/8/docs/api/java/lang/Math. html the API...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • Write a python program where you create a list (you an create it in code you...

    Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...

  • Using C programming language Question 1 a) through m) Exercise #1: Write a C program that...

    Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....

  • Please help. I need a very simple code. For a CS 1 class. Write a program...

    Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...

  • C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the...

    C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Using Python3, How can I aggregate the output from each iteration to one single list? Because...

    Using Python3, How can I aggregate the output from each iteration to one single list? Because from the program I have right now, it gives me the result of every iteration and gives me something like this as individual results and not one large list: None None ... None 130.0 None ... 1764 1765 None To clarify, I have this program where it calculates the sum of bytes sent within each incrementation of every 1 second, but there are instances...

  • Language: Java 30 pts. ) - This assignment revisits the student parsing program from earlier in...

    Language: Java 30 pts. ) - This assignment revisits the student parsing program from earlier in the quarter, but challenges you to restructure the component pieces of the program to create a cleaner, more succinct Main(). You will generate a Student class of object and load an Array List with student objects, then report the contents of that Array List. To do so, you must perform the following: A)(10 /30 pts.)- Generate a class file “myStudent.java” (which will generate myStudent.class...

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