Your can use the following template to help layout your code: # Don't forget Name and ID. # Don't forget to place your imports here. def calculate_distance(first_intensity, second_intensity): # implement your solution here # return distance #Ask user for itensity1 # Ask user for itensity2 # Validate your intensities. # In your if, elif, else block(s), you will need to place this # in the case where the distance is valid distance = calculate_distance(intensity1, intensity2) # Print results Part 3: Modify your program slightly so that you now take both intensities using a single input() statement. The user will enter the two values separated by a 'space' character (e.g., 10 5). Hints: Remember the split() string method covered in the class? Can you use this here? o Remember that you will need to cast the values to floats once you obtain the two measurements.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Part 3 only

Your can use the following template to help layout your code:
# Don't forget Name and ID.
# Don't forget to place your imports here.
def calculate_distance(first_intensity, second_intensity):
# implement your solution here
# return distance
#Ask user for itensity1
#Ask user for itensity2
# Validate your intensities.
# In your if, elif, else block(s), you will need to place this
# in the case where the distance is valid
distance = calculate_distance(intensity1, intensity2)
#Print results
Part 3:
Modify your program slightly so that you now take both intensities using a single
input() statement. The user will enter the two values separated by a 'space' character
(e.g., 10 5).
Hints:
Remember the split() string method covered in the class? Can you use this here?
O Remember that you will need to cast the values to floats once you obtain
the two measurements.
Part 4:
It turns out that your measurement device isn't very accurate and gives you slightly
different values each time you measure the intensity at a location. In order to obtain a
good estimate of the distance from the speaker and its power, you decide to repeat your
experiment multiple times and record the distance and power values for each run. You
then find the trimmed average of both the distance values and power values obtained
across your experiment.
Trimmed average or conservative average here is defined as the average of a list of
numbers ignoring the largest and smallest values. This was covered in a tutorial session
on lists, so feel free to refer to the appropriate content on D2L if you need a refresher.
Transcribed Image Text:Your can use the following template to help layout your code: # Don't forget Name and ID. # Don't forget to place your imports here. def calculate_distance(first_intensity, second_intensity): # implement your solution here # return distance #Ask user for itensity1 #Ask user for itensity2 # Validate your intensities. # In your if, elif, else block(s), you will need to place this # in the case where the distance is valid distance = calculate_distance(intensity1, intensity2) #Print results Part 3: Modify your program slightly so that you now take both intensities using a single input() statement. The user will enter the two values separated by a 'space' character (e.g., 10 5). Hints: Remember the split() string method covered in the class? Can you use this here? O Remember that you will need to cast the values to floats once you obtain the two measurements. Part 4: It turns out that your measurement device isn't very accurate and gives you slightly different values each time you measure the intensity at a location. In order to obtain a good estimate of the distance from the speaker and its power, you decide to repeat your experiment multiple times and record the distance and power values for each run. You then find the trimmed average of both the distance values and power values obtained across your experiment. Trimmed average or conservative average here is defined as the average of a list of numbers ignoring the largest and smallest values. This was covered in a tutorial session on lists, so feel free to refer to the appropriate content on D2L if you need a refresher.
Power?
Speaker
Distance?
Initial
Location
Imagine that you are on a straight, flat road. Some distance ahead, you spot a speaker
playing some music. You want to work out: 1) The distance of the speaker from your
location, and 2) the power of the source speaker. Unfortunately, you are unable to get
any closer to the source from your location, so you have to find an alternative way of
estimating its power and distance. Use the image above to help you visualise the
problem. Fortunately for you, you have a device that measures the intensity of sound at
your location. How do you go about using the intensity information to work out the
distance and power of the speaker?
1 =
According to laws of physics, under ideal conditions, sound propagates outwards from a
source in a radial fashion. Therefore, given the distance (r) (in metres) and the source
power (P) (in Watts), the intensity of sound (I) (in Watts/metre^2) at that distance is
given by the equation:
Repeat
Measurement
P
Area of sphere with radius ir
P
4πr²
Feel free to search the internet for more background on the inverse square law. For this
problem, you can assume that there is nothing between you and the speaker to absorb
or reflect any part of the sound, you can ignore the effect of the ground on the sound
waves, and that the speaker is at the same height as you (i.e., ignore the effect of
height). Your device measures the intensity in Watts per Squared Meter. To determine
the distance and power, you are smart enough to realize you need two measurements,
so you take 1 measurement (1₁) at your current location and take another one (1₂) after
stepping 1 meter backwards.
Transcribed Image Text:Power? Speaker Distance? Initial Location Imagine that you are on a straight, flat road. Some distance ahead, you spot a speaker playing some music. You want to work out: 1) The distance of the speaker from your location, and 2) the power of the source speaker. Unfortunately, you are unable to get any closer to the source from your location, so you have to find an alternative way of estimating its power and distance. Use the image above to help you visualise the problem. Fortunately for you, you have a device that measures the intensity of sound at your location. How do you go about using the intensity information to work out the distance and power of the speaker? 1 = According to laws of physics, under ideal conditions, sound propagates outwards from a source in a radial fashion. Therefore, given the distance (r) (in metres) and the source power (P) (in Watts), the intensity of sound (I) (in Watts/metre^2) at that distance is given by the equation: Repeat Measurement P Area of sphere with radius ir P 4πr² Feel free to search the internet for more background on the inverse square law. For this problem, you can assume that there is nothing between you and the speaker to absorb or reflect any part of the sound, you can ignore the effect of the ground on the sound waves, and that the speaker is at the same height as you (i.e., ignore the effect of height). Your device measures the intensity in Watts per Squared Meter. To determine the distance and power, you are smart enough to realize you need two measurements, so you take 1 measurement (1₁) at your current location and take another one (1₂) after stepping 1 meter backwards.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education