Calculate Channel Capacity, Minimum Bandwidth and Minimum Signal to Noise Ratio | Python

In this we are going to see a basic example of Calculating channel capacity, minimum bandwidth, minimum signal to noise ratio using python.

import math

# Capacity Calculation
def Capacity():
    B = int(input("Enter the value of Bandwidth: "))
    SNR = int(input("Enter the Signal to Noise Ratio: "))
    C = round(B * math.log((1+SNR), 2), 3)
    print("Gaussian Channel Capacity = ", C, " bps\n")


# Bandwidth Calculation
def Bandwidth():
    Capacity = int(input("Enter the Gaussian Channel Capacity: "))
    snr = int(input("Enter the Signal to Noise Ratio: "))
    Bandwidth = round(Capacity/math.log((1+snr), 2), 3)
    print("Bandwidth = ", Bandwidth, "Hz\n")


# Signal to Noise Ration Calculation
def Signal_to_Noise():
    capacity = int(input("Enter the Gaussian Channel Capacity: "))
    bandwidth = int(input("Enter the value of Bandwidth: "))
    SNR = round((math.pow(2, (capacity/bandwidth))-1), 3)
    print("Signal to Noise Ration = ", SNR, "\n")


user = int(input("Enter the Corresponding number of operation\n1 : Capacity Calculation \n2 : Bandwidth Calculation \n3 : Signal to Noise Ratio Calculation\n0: Exit\n"))

while user != 0:
    if user == 1:
        Capacity()
    elif user == 2:
        Bandwidth()
    elif user == 3:
        Signal_to_Noise()
    else:
        print("Invalid Input!!!")
    user = int(input("Enter the Corresponding number of operation\n1 : Capacity Calculation \n2 : Bandwidth Calculation \n3 : Signal to Noise Ratio Calculation\n0: Exit\n"))

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post