Categories

Find the PEP errors:

The following code has 10 PEP8 Violations, can you find them all?
Code Sample with PEP 8 Violations

import math,sys;

def example1(x,y): return x+y

def example2(x,y): 
  print(x+y)

class myClass:
  def __init__(self,r):self.radius=r
  def calc_area(self):
    return math.pi*self.radius**2

def run():
    print("Hello, world!")
    print(example1(1,2))
    example2(3, 4)
    C=myClass(5)
    print("Area is:",C.calc_area())

if __name__== "__main__":run()
Answer Key

Leave a Reply

Your email address will not be published. Required fields are marked *