From fba6888a5f93e54abd4931c93605249bf7113628 Mon Sep 17 00:00:00 2001 From: rakesh Date: Mon, 23 Dec 2019 12:41:55 +0530 Subject: [PATCH] IP assignments --- Loops/emi_calculator.py | 21 +++++++++++++++++++++ Loops/gcd_two.py | 22 ++++++++++++++++++++++ Loops/tempCodeRunnerFile.py | 2 ++ functions/recursion/gcd_recursion.py | 12 ++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 Loops/emi_calculator.py create mode 100644 Loops/gcd_two.py create mode 100644 Loops/tempCodeRunnerFile.py create mode 100644 functions/recursion/gcd_recursion.py diff --git a/Loops/emi_calculator.py b/Loops/emi_calculator.py new file mode 100644 index 0000000..a8ef623 --- /dev/null +++ b/Loops/emi_calculator.py @@ -0,0 +1,21 @@ +# program to find out EMI using formula +# EMI = (p*r(1+r)**t)/((1+r)**t-1) +# made by : rakesh kumar + +from math import pow + + +def emi_calculate(p, r, t): + r = r/(12*100) # rate for one month + t = t*12 # one month time + emi = (p*r*pow(1+r, t))/(pow(1+r, t)-1) + return emi + + +if __name__ == "__main__": + p = int(input('Enter pricipal amount :')) + r = int(input('Enter rate of interest :')) + t = int(input('Enter time in years :')) + emi = emi_calculate(p, r, t) + + print('Monthly Installment :%.2f' % emi) diff --git a/Loops/gcd_two.py b/Loops/gcd_two.py new file mode 100644 index 0000000..7eab999 --- /dev/null +++ b/Loops/gcd_two.py @@ -0,0 +1,22 @@ +# program to find out GCD of two number using iterative method +# made by : rakeseh kumar + + +a = int(input('Enter any number')) +b = int(input('Enter another number')) + +""" if(a > b): + number = a + divider = b +else: + number = b + divider = a """ + +rem = a % b + +while(rem != 0): + a = b + b = rem + rem = a % b + +print('Your GCD is :', b) diff --git a/Loops/tempCodeRunnerFile.py b/Loops/tempCodeRunnerFile.py new file mode 100644 index 0000000..af35f1b --- /dev/null +++ b/Loops/tempCodeRunnerFile.py @@ -0,0 +1,2 @@ + + r = int(input('Enter rate of interest amount :')) \ No newline at end of file diff --git a/functions/recursion/gcd_recursion.py b/functions/recursion/gcd_recursion.py new file mode 100644 index 0000000..95ba867 --- /dev/null +++ b/functions/recursion/gcd_recursion.py @@ -0,0 +1,12 @@ +def gcd(a, b): + if(b == 0): + return a + else: + return gcd(b, a % b) + + +if __name__ == "__main__": + a = int(input('Enter first number ')) + b = int(input('Enter second number ')) + result = gcd(a, b) + print('GCD of {} and {} is {}'.format(a, b, result))