From 678e348541136b44d0582be38eaee2330636afc6 Mon Sep 17 00:00:00 2001 From: Pratik Sanghani Date: Wed, 9 Oct 2019 21:29:03 +0530 Subject: [PATCH 1/5] Quick Sort --- quick_sort.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 quick_sort.py diff --git a/quick_sort.py b/quick_sort.py new file mode 100644 index 0000000..5ddf3fe --- /dev/null +++ b/quick_sort.py @@ -0,0 +1,19 @@ +def partition(arr,low,high): + i = ( low-1 ) + pivot = arr[high] + + for j in range(low , high): + if arr[j] <= pivot: + i = i+1 + arr[i],arr[j] = arr[j],arr[i] + + arr[i+1],arr[high] = arr[high],arr[i+1] + return ( i+1 ) + + +def quickSort(arr,low,high): + if low < high: + pi = partition(arr,low,high) + + quickSort(arr, low, pi-1) + quickSort(arr, pi+1, high) \ No newline at end of file From 336c9a971013b85159b46f0ee27e6392b902fb80 Mon Sep 17 00:00:00 2001 From: shyamkanani Date: Wed, 9 Oct 2019 23:58:51 +0530 Subject: [PATCH 2/5] Python Program for calculator --- calculator.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 calculator.py diff --git a/calculator.py b/calculator.py new file mode 100644 index 0000000..68da8fb --- /dev/null +++ b/calculator.py @@ -0,0 +1,19 @@ +a=int(input("Enter first no. ")) +b=int(input("Enter second no. ")) +print("Your Options;Select one:") +print("+ for sum") +print("- for sub") +print("* for mul") +print("/ for div") +n=input("Your choice ") +print("Result is... ") +if n == '+': + print(a + b) +elif n == '-': + print(a - b) +elif n == '*': + print(a * b) +elif n == '/': + print(a / b) +else: + print("Enter valid choice") From d78e4bcc7595ded287825cf880fa2eec131fb88b Mon Sep 17 00:00:00 2001 From: Pratik Sanghani Date: Thu, 10 Oct 2019 22:36:29 +0530 Subject: [PATCH 3/5] Revert "Added Python Program for calculator" --- calculator.py | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 calculator.py diff --git a/calculator.py b/calculator.py deleted file mode 100644 index 68da8fb..0000000 --- a/calculator.py +++ /dev/null @@ -1,19 +0,0 @@ -a=int(input("Enter first no. ")) -b=int(input("Enter second no. ")) -print("Your Options;Select one:") -print("+ for sum") -print("- for sub") -print("* for mul") -print("/ for div") -n=input("Your choice ") -print("Result is... ") -if n == '+': - print(a + b) -elif n == '-': - print(a - b) -elif n == '*': - print(a * b) -elif n == '/': - print(a / b) -else: - print("Enter valid choice") From 9f93079e9469e006fd0c8adae4d5d69f2bcbbcec Mon Sep 17 00:00:00 2001 From: rudri182 Date: Fri, 11 Oct 2019 16:07:22 +0530 Subject: [PATCH 4/5] add program to display fibonacci sereis --- Fibonacci.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Fibonacci.py diff --git a/Fibonacci.py b/Fibonacci.py new file mode 100644 index 0000000..5c4a6b1 --- /dev/null +++ b/Fibonacci.py @@ -0,0 +1,28 @@ +# Program to display the Fibonacci sequence up to n-th term where n is provided by the user + +# change this value for a different result +#nterms = 10 + +# uncomment to take input from the user +nterms = int(input("How many terms? ")) + +# first two terms +n1 = 0 +n2 = 1 +count = 0 + +# check if the number of terms is valid +if nterms <= 0: + print("Please enter a positive integer") +elif nterms == 1: + print("Fibonacci sequence upto",nterms,":") + print(n1) +else: + print("Fibonacci sequence upto",nterms,":") + while count < nterms: + print(n1,end=' , ') + nth = n1 + n2 + # update values + n1 = n2 + n2 = nth + count += 1 From 64920fa2e105ecb8d259f5c975e1bccb98811558 Mon Sep 17 00:00:00 2001 From: BansiJoshi Date: Mon, 14 Oct 2019 19:35:02 +0530 Subject: [PATCH 5/5] Factorial program in python --- factorial.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 factorial.py diff --git a/factorial.py b/factorial.py new file mode 100644 index 0000000..41a6ca2 --- /dev/null +++ b/factorial.py @@ -0,0 +1,8 @@ +fact = 1 +n = int(input("Enter value:")) + +for i in range(1,n+1): + fact = fact * i + +print("Factorial of " + str(n) + " is " + str(fact)) +