基于重叠的IF语句

时间:2019-03-04 08:18:22

标签: python-3.x if-statement range overlap

我正在尝试在python 3.7中创建一个简单的函数,该函数返回特定放大器是否符合出口规定。 该标准取决于饱和功率,频率范围和小数带宽。

从下面的示例中可以看到,顺应性阈值随着频率的增加而降低,这使得查找频率端点变得很简单。除了31.8-37GHz的条件。

有人可以建议对我的代码进行更改,以便任何与标准重叠的频率范围都被标记吗?

def amplifier():
    freq_start = float(input('Start frequency in GHz: '))
    freq_stop = float(input('Stop frequency in Ghz: '))
    psat = float(input('Saturated power in dBm: '))
    fractional_bw = (freq_stop-freq_start)/((freq_start+freq_stop)/2)

    if 16 < freq_stop <= 31.8 and fractional_bw > 0.10 and psat > 34.77:
        return 'Export compliance according to 3A001.b.2.c'

    if 31.8 < freq_stop <= 37 and psat > -70:
        return 'Export compliance according to 3A001.b.2.d'

    if 37 < freq_stop <= 43.5 and fractional_bw > 0.10 and psat > 30:
        return 'Export compliance according to 3A001.b.2.e'

    if 43.5 < freq_stop <= 75 and fractional_bw > 0.10 and psat > 15:
        return 'Export compliance according to 3A001.b.2.f'

    if 75 < freq_stop <= 90 and fractional_bw > 0.05 and psat > 10:
        return 'Export compliance according to 3A001.b.2.g'

    if 90 < freq_stop and psat > -70:
        return 'Export compliance according to 3A001.b.2.h'

    else:
        return 'Not export compliance according to 3A001.b.2'

0 个答案:

没有答案
相关问题