Dec-07-2021, 01:23 PM
Hello, I am struggling to define a function and I'm finding my reading material isn't really helping or explaining correctly. I'm not looking for the complete answer to my question. Just some general pointers in the right direction.
The question:
Let us suppose a 5 GHz radio wave that:
propagates through the atmosphere in rainy weather over a distance d, in kilometres (km)
and then through one layer of wood of thickness t, in metres (m).
The problem
The problem is to write a function to calculate the total power loss, measured in dB (decibel), under those circumstances given that:
rain leads to an atmospheric loss of 1.5 decibel per kilometre (dB/km)
wood leads to a further loss of 90 decibel per metre (dB/m)
to account for other unknown noise and impairments that might be present, the combined loss (obtained by adding the loss from 1 and 2) is multiplied by your individual number 1.0XYZ. This gives you the total loss.
You can test your approach with typical values of d = 30 km and t = 0.1 m (which should result in a combined loss of 54 dB, which must then be multiplied by your individual number in order to find the total loss).
The function should have two arguments: one for the distance d and one for the thickness t of the layer of wood.
The function should have one return value for the total power loss.
The question:
Let us suppose a 5 GHz radio wave that:
propagates through the atmosphere in rainy weather over a distance d, in kilometres (km)
and then through one layer of wood of thickness t, in metres (m).
The problem
The problem is to write a function to calculate the total power loss, measured in dB (decibel), under those circumstances given that:
rain leads to an atmospheric loss of 1.5 decibel per kilometre (dB/km)
wood leads to a further loss of 90 decibel per metre (dB/m)
to account for other unknown noise and impairments that might be present, the combined loss (obtained by adding the loss from 1 and 2) is multiplied by your individual number 1.0XYZ. This gives you the total loss.
You can test your approach with typical values of d = 30 km and t = 0.1 m (which should result in a combined loss of 54 dB, which must then be multiplied by your individual number in order to find the total loss).
The function should have two arguments: one for the distance d and one for the thickness t of the layer of wood.
The function should have one return value for the total power loss.
def decibel_test(atmospheric_loss,decibel_loss,total_loss,rain,unique_number): """calculate the loss in decibels over a pre determined distance""" atmospheric_loss = rain * distance decibel_loss = timber_loss + atmospheric_loss total_loss = decibel_loss * unique_number unique_number = 1.01993 rain = 1.5 print('distance in km') distance=float(input()) print('wood in metres') timber_loss = 0.1 * float(input()) DB_loss=decibel_test(distance,timber_loss,rain,unique_number) print('the total decibel loss is', DB_loss)
Error:Traceback (most recent call last):
File "C:\Users\Andrew\OneDrive - The Open University\TM112\TMA02\Question 4.py", line 16, in <module>
DB_loss=decibel_test(distance,timber_loss,rain,unique_number)
NameError: name 'rain' is not defined
If I fix the rain is not defined issue, I know I'll end up coming across more. This is about as far as I can get with the materials provided.