Skip to content

Commit

Permalink
removed unnessary variables and added pep8 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayanth authored and Jayanth committed Jun 19, 2019
1 parent b145e70 commit 51b5c4e
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 48 deletions.
10 changes: 4 additions & 6 deletions Circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

PI = 3.14

#r*r is repesents squire and PI =3.14
# r*r is repesents squire and PI =3.14
def area(r):
ar = PI * (r**2)
return ar
return PI * (r**2)


# 2 multiply PI=3.14 multiply r
def cir(r):
cir = PI * (2 * r)
return cir
def circumference(r):
return PI * (2 * r)


# Main
Expand Down
9 changes: 6 additions & 3 deletions factorial.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# This program is to print factorial

def factorial(num):
factor=1
factor = 1

for i in range(1,num+1,1):
factor*=i
factor *= i

return factor

#main

# main
if __name__ == "__main__":
nums=int(input("Enter the number for factorial: "))
print("factorial of ",nums," is ",factorial(nums))
9 changes: 4 additions & 5 deletions fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#This program is to print Nth fibonacci number
# This program is to print Nth fibonacci number

t0,t1 = 0,1

def fibon(t0,t1):
def fibon(t0 = 0, t1 = 1):
temp= t0+t1
t0=t1
t1=temp
return t0,t1


def display(num,t0,t1):
i=0
list=[0,1]
Expand All @@ -21,7 +20,7 @@ def display(num,t0,t1):
return list


#main
# main
if __name__ == "__main__":
num= int(input("Enter the number: "))
list=display(num,t0,t1)
Expand Down
6 changes: 3 additions & 3 deletions find_div.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# This is program is used to display Divisible of 7 and Note multiply of 5

#second loading fn
# Second loading fn
def div_7(num,num2):
list=[]
for i in range(num,num2+1,1):
if (i%7 == 0):
list.append(i)
return list

#first loading fn
# First loading fn
def mult_5(num,num2):
ls=[]
l= div_7(num,num2)
Expand All @@ -19,7 +19,7 @@ def mult_5(num,num2):
ls.append(i)
return ls

#main
# Main
if __name__== "__main__":
num = 2000
num2 = 3200
Expand Down
6 changes: 2 additions & 4 deletions gcd.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# This program is to find the GCD(Greatest Commen Factore or Diviser)

def gcd(val,val1):

while(val1):

val, val1= val1, val%val1
val, val1 = val1, val%val1

return val

# Main
if __name__ == "__main__":
print("GCD of 16,24 is",gcd(16,24))
print("GCD of 20, 19 is",gcd(390,6777))
11 changes: 4 additions & 7 deletions largest_num.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

# Function to check largest Number
def largest(num1,num2,num3):

if (num1>num2) and (num1>num3):
if num1 > num2 and num1 > num3:
return num1

elif (num2>num3) and (num2>num1):
elif num2 > num3 and num2 > num1:
return num2

elif (num3>num1) and (num3>num2):
elif num3 > num1 and num3 > num2:
return num3

# Main
if __name__=="__main__":
num1=(input("Enter the 1st Number"))
num2=(input("Enter the 2st Number"))
num3=(input("Enter the 3st Number"))

print(largest(num1,num2,num3))
4 changes: 2 additions & 2 deletions lcd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This program is used to display LCD of two numbers

import gcd
from gcd import gcd

def lcd(num,num1):
gcd_val = gcd.gcd(num,num1)
gcd_val = gcd(num,num1)
given_mul = num*num1
lcd_val = (given_mul//gcd_val)
return lcd_val
Expand Down
10 changes: 6 additions & 4 deletions list_larg.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#This program
# This program

def largest(num):
l = len(num)
# print(l)
val=0

for i in range(0,l,1):
if val<=num[i]:
val=num[i]
return val

#main
return val4


# Main
if __name__ =="__main__":
lists = [5,11,2,3,6,4,7,8,10,9,1]
print("The largest Number is the given list is ",largest(lists))
7 changes: 4 additions & 3 deletions list_odd_even.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#This program is used to print odd first and even at last
# This program is used to print odd first and even at last


def find(list):
temp1=[]
temp2=[]

for i in list:
if i%2 == 0:
temp1.append(i)
#print(temp1)
else:
temp2.append(i)
#print(temp2)

return temp2+temp1


#main
if __name__=="__main__":
lists = [0,1,2,3,4,5,6,7,8,9,10]
Expand Down
2 changes: 1 addition & 1 deletion list_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


def sums(num):

sum1=0
sum2=0

Expand All @@ -11,6 +10,7 @@ def sums(num):
sum1+=i
else:
sum2+=i

return sum1,sum2

#main
Expand Down
3 changes: 2 additions & 1 deletion next_prime.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#This program

def nex_prime(num):
if num ==0 or num ==1:
if num == 0 or num == 1:
num=1

for i in range(num+1, (num+1)*2, 1):
if prime(i):
return i
Expand Down
4 changes: 2 additions & 2 deletions palindrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ def palindrome(str):

# Main
if __name__ == "__main__":
x=palindrome("mom")
user_input = palindrome("mom")

if x:
if user_input:
print("is palindrome")
else:
print("is not palindrome")
7 changes: 4 additions & 3 deletions previous_prime.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@


def previous_prime(num):
for i in range( num-1 , 1 , -1 ):
if prime(i):
return i


def prime(num):
if num == 2:
return True
elif num%2==0:
elif num%2 == 0:
return False

for i in range(3, (num//3),2):
Expand All @@ -17,7 +17,8 @@ def prime(num):

return True

#mani

# mani
if __name__ == "__main__":
num= int(input("Enter the Number: "))

Expand Down
2 changes: 1 addition & 1 deletion radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Radius Formula for Circle Radius= Area divided by PI
def Radius(area):
r = area/PI
Rad=math.sqrt(r)
Rad = math.sqrt(r)
#rad is Radius
return Rad

Expand Down
5 changes: 2 additions & 3 deletions string_len.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#this program

def str_len(l):
length=len(l)
return length
def str_len(string):
return len(string)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions text_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def checking_line():
file.close()
return count


# Main
if __name__=="__main__":
print(checking_line())

0 comments on commit 51b5c4e

Please sign in to comment.