Programming With the List of Elevations, Latitudes, & Longitudes Pseudocode
Using CodeHS Sandbox, write a program using the following guidelines:
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.
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
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()
Programming With the List of Elevations, Latitudes, & Longitudes Pseudocode Using CodeHS Sandbox, write a program...
Directions: Write a code for the following programming exercise in PYTHON!!!!!!! -Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Here is what i got so far, but for some reason this code only print the Minimum and Maximum. its not printing the Average. def...
How can I modify my program to accept a list of integers (up to 20 entries) from the user into a list and prints the numbers entered by the user in ascending order, their sum and their average. The program then stops when the user inputs -100 as a number to search. #function that returns largest number def max(numOne,numTwo,numThree): if(numOne > numTwo and numOne > numThree): return numOne elif(numTwo > numOne and numTwo > numThree): return numTwo elif(numThree > numOne...
***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 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[]) 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 program (a3.py) that has 3 function definitions: magic-sequential(), magic-binary(), and main(). You will write the code for the above functions. Both magic functions (magic-sequential() and magic-binary()) will look for a magic index in a given sorted list of distinct integers. A magic index in a list myList[0 ... n-1] is defined to be an index i such that myList[i] = i . Both functions receive the list as a parameter and return an integer: either the magic index,...
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...
I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...
Write the code in python programming Language String Statistics: Write a program that reads a string from the user and displays the following information about the string: (a) the length of the string, (b) a histogram detailing the number of occurrences of each vowel in the string (details provided below), (c) the number of times the first character of the string occurs throughout the entire string, (d) the number of times the last character of the string occurs throughout the...
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....