expected two blank lines pep8 warning in python

前端 未结 5 2050
不知归路
不知归路 2020-12-25 13:44

I\'m using vim editor as python IDE. Below is a simple python program to calculate square root of a number:

import cmath
def sqrt():
    try:
        num = i         


        
5条回答
  •  旧时难觅i
    2020-12-25 14:28

    All answers seem to be correct. To avoid doing this by hand, you can also use the autopep8 package (pip install autopep8). The result of calling autopep8 filename.py is the same:

    import cmath
    
    
    def sqrt():
        try:
            num = int(input("Enter the number : "))
            if num >= 0:
                main(num)
            else:
                complex(num)
        except:
            print("OOPS..!!Something went wrong, try again")
            sqrt()
        return
    
    
    def main(num):
        squareRoot = num**(1/2)
        print("The square Root of ", num, " is ", squareRoot)
        return
    
    
    def complex(num):
        ans = cmath.sqrt(num)
        print("The Square root if ", num, " is ", ans)
        return
    
    
    sqrt()
    

    PS: have a look at if __name__ == "__main__":

提交回复
热议问题