From e922ede4a72d5021d196406c3d47ec8be0627818 Mon Sep 17 00:00:00 2001 From: Mgeethabhargava Date: Sat, 3 Oct 2020 14:48:24 +0530 Subject: [PATCH 01/36] new javascript programs --- Javascript/program-6/read.md | 2 +- Javascript/program-7/program-7.html | 33 +++++++++++++++++++++++++++++ Javascript/program-7/read.md | 4 ++++ Javascript/program-8/program-8.html | 21 ++++++++++++++++++ Javascript/program-8/read.md | 4 ++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 Javascript/program-7/program-7.html create mode 100644 Javascript/program-7/read.md create mode 100644 Javascript/program-8/program-8.html create mode 100644 Javascript/program-8/read.md diff --git a/Javascript/program-6/read.md b/Javascript/program-6/read.md index 61cc055a..41027f16 100644 --- a/Javascript/program-6/read.md +++ b/Javascript/program-6/read.md @@ -1,3 +1,3 @@ -# Program-4 +# Program-6 ## This is a javascript program for character processing diff --git a/Javascript/program-7/program-7.html b/Javascript/program-7/program-7.html new file mode 100644 index 00000000..02f877bc --- /dev/null +++ b/Javascript/program-7/program-7.html @@ -0,0 +1,33 @@ + + +Searching strings with index Of amd LastIndex of + + + + +
+

The String to search is:
abcdefghijklmnopqrstuvwxyzabcdefghijklm

+

Enter substring to search for + +

+

First Occurace located at index + +
Last occurance located at index + +
First occurance from index l2 located at index + +
last occurance from index l2 located at index +

+
+ + diff --git a/Javascript/program-7/read.md b/Javascript/program-7/read.md new file mode 100644 index 00000000..58c8bbb4 --- /dev/null +++ b/Javascript/program-7/read.md @@ -0,0 +1,4 @@ +# Program-7 + +## This is a javascript program for string searching + diff --git a/Javascript/program-8/program-8.html b/Javascript/program-8/program-8.html new file mode 100644 index 00000000..9fc48e1e --- /dev/null +++ b/Javascript/program-8/program-8.html @@ -0,0 +1,21 @@ + + + + + + + + +

When you click "Try it", a function will be called.

+

The function will display a message.

+ + + +

+ + + \ No newline at end of file diff --git a/Javascript/program-8/read.md b/Javascript/program-8/read.md new file mode 100644 index 00000000..b6c0dfd5 --- /dev/null +++ b/Javascript/program-8/read.md @@ -0,0 +1,4 @@ +# Program-8 + +## This is a javascript program for javascript function basic program + From 36d3cf2cd0fae3f7b74d47fa8416214a01b4ee31 Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Sun, 4 Oct 2020 08:58:47 +0530 Subject: [PATCH 02/36] added readme.md.py --- Python/program-5/readme.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Python/program-5/readme.md diff --git a/Python/program-5/readme.md b/Python/program-5/readme.md new file mode 100644 index 00000000..2d1679fb --- /dev/null +++ b/Python/program-5/readme.md @@ -0,0 +1,15 @@ +PROGRAM-5 +To print the pattern in the form + 1 + 1 2 1 2 + 1 2 3 1 2 3 + 1 2 3 4 1 2 3 4 +1 2 3 4 5 1 2 3 4 5 + + AND + +1 +2 2 +3 3 3 +4 4 4 4 +5 5 5 5 5 \ No newline at end of file From 5b6a5e81eb31d0c28f646a98de3cc50fb98b1b8e Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Sun, 4 Oct 2020 20:13:27 +0530 Subject: [PATCH 03/36] added readme.md.py --- Python/program-5/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/program-5/readme.md b/Python/program-5/readme.md index 2d1679fb..45471789 100644 --- a/Python/program-5/readme.md +++ b/Python/program-5/readme.md @@ -1,12 +1,12 @@ PROGRAM-5 -To print the pattern in the form +To print the given pattern(pattern.py) 1 1 2 1 2 1 2 3 1 2 3 1 2 3 4 1 2 3 4 1 2 3 4 5 1 2 3 4 5 - AND + AND(pattern1.py) 1 2 2 From 73788a230f72055779365d3018ee6b0b32f1aa90 Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Sun, 4 Oct 2020 22:01:57 +0530 Subject: [PATCH 04/36] added readme.md --- Python/program-6/readme.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Python/program-6/readme.md diff --git a/Python/program-6/readme.md b/Python/program-6/readme.md new file mode 100644 index 00000000..61af2e38 --- /dev/null +++ b/Python/program-6/readme.md @@ -0,0 +1,6 @@ +program to print the given pattern +1 +2 2 +3 3 3 +4 4 4 4 +5 5 5 5 5 \ No newline at end of file From c6fcd94de80aaac226d7841c93fad734591759f9 Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Sun, 4 Oct 2020 22:06:04 +0530 Subject: [PATCH 05/36] removed pattern1.py --- Python/program-5/pattern1.py | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Python/program-5/pattern1.py diff --git a/Python/program-5/pattern1.py b/Python/program-5/pattern1.py deleted file mode 100644 index 2011dd0f..00000000 --- a/Python/program-5/pattern1.py +++ /dev/null @@ -1,11 +0,0 @@ -#pattern -for i in range(1,6): - for j in range(1,6-i): - print(" ",end=" ") - for k in range(1,i+1): - print(k,end=" ") - if i>1: - for l in range(1,i+1): - print(l,end=" ") - print() - \ No newline at end of file From c05a5b021fef1467bf77bf75ae0e7ad194393cf6 Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Sun, 4 Oct 2020 22:08:07 +0530 Subject: [PATCH 06/36] modified readme.md --- Python/program-5/readme.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Python/program-5/readme.md b/Python/program-5/readme.md index 45471789..49831857 100644 --- a/Python/program-5/readme.md +++ b/Python/program-5/readme.md @@ -1,15 +1,7 @@ PROGRAM-5 To print the given pattern(pattern.py) - 1 + 1 1 2 1 2 1 2 3 1 2 3 1 2 3 4 1 2 3 4 1 2 3 4 5 1 2 3 4 5 - - AND(pattern1.py) - -1 -2 2 -3 3 3 -4 4 4 4 -5 5 5 5 5 \ No newline at end of file From 594a6b4f98818da66e87ea38a363fb03f0c45f97 Mon Sep 17 00:00:00 2001 From: just-tech20 <62553925+just-tech20@users.noreply.github.com> Date: Mon, 5 Oct 2020 01:54:30 +0530 Subject: [PATCH 07/36] find prime numbers between numbers added a program to find the prime numbers between the numbers --- C/Program-61/program.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 C/Program-61/program.c diff --git a/C/Program-61/program.c b/C/Program-61/program.c new file mode 100644 index 00000000..0e7c906c --- /dev/null +++ b/C/Program-61/program.c @@ -0,0 +1,58 @@ +/* + This Program calulates all the prime between the range of numbers + includes the numbers which is provided. + + For e.g: 2 7 + Prime Numbers are : 2 3 5 7 +*/ + +#include +#include + +char primecheck(int); + +int main() +{ + int i,num1,num2,cases; + char ans; + printf("Enter Number of Test Cases: "); + scanf("%d",&cases); + while (cases--) + { + printf("Enter First Number: "); + scanf("%d",&num1); + printf("Enter Second Number: "); + scanf("%d",&num2); + + printf("Answer: "); + for(i=num1;i<=num2;i++) + { + ans = primecheck(i); + if (ans == 'y') + printf("%d ",i); + } + printf("\n"); + } + return 0; +} + +char primecheck(int num) +{ + int i; + if (num == 0 || num == 1) + return 'n'; + else + { + for(i=(num-1);i>1;i--) + { + if(num%i == 0) + { + return 'n'; + } + else + continue; + } + return 'y'; + } + +} \ No newline at end of file From 62f55330263be72a1d4767665b3af5ef04f6a866 Mon Sep 17 00:00:00 2001 From: just-tech20 <62553925+just-tech20@users.noreply.github.com> Date: Mon, 5 Oct 2020 01:56:20 +0530 Subject: [PATCH 08/36] Update README.md added program to find the prime number between the number --- C/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C/README.md b/C/README.md index 936b65b6..f5d269b5 100644 --- a/C/README.md +++ b/C/README.md @@ -62,6 +62,7 @@ | Program-58 | Program to find the sum of elements between indexes | | Program-59 | Program to Search Students details in a list | | Program-60 | Program to print kaprekar number in a given range | +| Program-61 | Program to find the all the prime numbers between the numbers | From 178b1141f3fa2a735f3b92a2b6e8d9094b9e609b Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Mon, 5 Oct 2020 08:45:00 +0530 Subject: [PATCH 09/36] renamed the file --- Python/{program-6 => program-10}/pattern2.py | 0 Python/{program-6 => program-10}/readme.md | 0 Python/{program-5 => program-9}/pattern.py | 0 Python/{program-5 => program-9}/readme.md | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Python/{program-6 => program-10}/pattern2.py (100%) rename Python/{program-6 => program-10}/readme.md (100%) rename Python/{program-5 => program-9}/pattern.py (100%) rename Python/{program-5 => program-9}/readme.md (100%) diff --git a/Python/program-6/pattern2.py b/Python/program-10/pattern2.py similarity index 100% rename from Python/program-6/pattern2.py rename to Python/program-10/pattern2.py diff --git a/Python/program-6/readme.md b/Python/program-10/readme.md similarity index 100% rename from Python/program-6/readme.md rename to Python/program-10/readme.md diff --git a/Python/program-5/pattern.py b/Python/program-9/pattern.py similarity index 100% rename from Python/program-5/pattern.py rename to Python/program-9/pattern.py diff --git a/Python/program-5/readme.md b/Python/program-9/readme.md similarity index 100% rename from Python/program-5/readme.md rename to Python/program-9/readme.md From de2518112281a828c83c1f57489a7a55b3171c2b Mon Sep 17 00:00:00 2001 From: mahi252001 Date: Mon, 5 Oct 2020 09:03:25 +0530 Subject: [PATCH 10/36] renamed the file --- Python/{program-9 => program-12}/pattern.py | 0 Python/{program-9 => program-12}/readme.md | 0 Python/{program-10 => program-13}/pattern2.py | 0 Python/{program-10 => program-13}/readme.md | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Python/{program-9 => program-12}/pattern.py (100%) rename Python/{program-9 => program-12}/readme.md (100%) rename Python/{program-10 => program-13}/pattern2.py (100%) rename Python/{program-10 => program-13}/readme.md (100%) diff --git a/Python/program-9/pattern.py b/Python/program-12/pattern.py similarity index 100% rename from Python/program-9/pattern.py rename to Python/program-12/pattern.py diff --git a/Python/program-9/readme.md b/Python/program-12/readme.md similarity index 100% rename from Python/program-9/readme.md rename to Python/program-12/readme.md diff --git a/Python/program-10/pattern2.py b/Python/program-13/pattern2.py similarity index 100% rename from Python/program-10/pattern2.py rename to Python/program-13/pattern2.py diff --git a/Python/program-10/readme.md b/Python/program-13/readme.md similarity index 100% rename from Python/program-10/readme.md rename to Python/program-13/readme.md From ef03f5057b56be16bb5dbb9c447bfa7384f697b4 Mon Sep 17 00:00:00 2001 From: Akashkpdroid <71496133+Akashkpdroid@users.noreply.github.com> Date: Mon, 5 Oct 2020 10:41:08 +0530 Subject: [PATCH 11/36] Very short way to find vowels find vowels in string fast process --- Java/program-3/program.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Java/program-3/program.java b/Java/program-3/program.java index a108adc6..95be6346 100644 --- a/Java/program-3/program.java +++ b/Java/program-3/program.java @@ -8,10 +8,10 @@ public static void main(String args[]) int v=0; for(int i=0;i Date: Mon, 5 Oct 2020 11:23:45 +0530 Subject: [PATCH 12/36] added program --- Python/program-17/Bitodec.py | 14 ++++++++++++++ Python/program-17/readme.md | 1 + 2 files changed, 15 insertions(+) create mode 100644 Python/program-17/Bitodec.py create mode 100644 Python/program-17/readme.md diff --git a/Python/program-17/Bitodec.py b/Python/program-17/Bitodec.py new file mode 100644 index 00000000..c64a9c0b --- /dev/null +++ b/Python/program-17/Bitodec.py @@ -0,0 +1,14 @@ +#Python Program to Convert Decimal to Binary + +def decimalToBinary(num): + """This function converts decimal number + to binary and prints it""" + if num > 1: + decimalToBinary(num // 2) + print(num % 2, end='') + + +# decimal number +number = int(input("Enter any decimal number: ")) + +decimalToBinary(number) \ No newline at end of file diff --git a/Python/program-17/readme.md b/Python/program-17/readme.md new file mode 100644 index 00000000..a217e327 --- /dev/null +++ b/Python/program-17/readme.md @@ -0,0 +1 @@ +Program to convert Binary to Decimal \ No newline at end of file From f290af50d8ec7af8d887e454ecbc10a49673d79b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Oct 2020 14:56:10 +0530 Subject: [PATCH 13/36] updated README.md --- Python/Program-3/README.md | 7 ------ Python/README.md | 24 +++++++++++++++++++ .../shufflecards.py => program-10/program.py} | 0 .../git.py => program-11/program.py} | 0 .../git1.py => program-12/program.py} | 0 .../git2.py => program-13/program.py} | 0 Python/{program-16 => program-13}/readme.md | 0 .../git3.py => program-14/program.py} | 1 - Python/program-14/readme.md | 1 - .../sorting.py => program-15/program.py} | 0 Python/program-15/readme.md | 1 - .../triangle.py => program-16/program.py} | 6 ++--- Python/program-18/readme.md | 1 - Python/program-2/program.py | 15 +++++++++++- Python/program-4/README.md | 2 -- Python/program-4/{Program 4.py => program.py} | 18 +++++++------- Python/program-5/README.md | 9 ++++--- Python/program-5/factorial.py | 14 ----------- Python/program-5/{pattern.py => pragram.py} | 0 Python/program-6/README.md | 9 ++++--- Python/program-6/pattern.py | 4 ---- Python/program-6/program.py | 18 ++++---------- Python/program-7/{pattern3.py => program.py} | 0 Python/program-8/{pattern4.py => program.py} | 0 .../armstrong.py => program-9/program.py} | 0 25 files changed, 66 insertions(+), 64 deletions(-) delete mode 100644 Python/Program-3/README.md create mode 100644 Python/README.md rename Python/{program-11/shufflecards.py => program-10/program.py} (100%) rename Python/{program-14/git.py => program-11/program.py} (100%) rename Python/{program-15/git1.py => program-12/program.py} (100%) rename Python/{program-16/git2.py => program-13/program.py} (100%) rename Python/{program-16 => program-13}/readme.md (100%) rename Python/{program-18/git3.py => program-14/program.py} (99%) delete mode 100644 Python/program-14/readme.md rename Python/{program-4/sorting.py => program-15/program.py} (100%) delete mode 100644 Python/program-15/readme.md rename Python/{program-4/triangle.py => program-16/program.py} (96%) delete mode 100644 Python/program-18/readme.md delete mode 100644 Python/program-4/README.md rename Python/program-4/{Program 4.py => program.py} (96%) delete mode 100644 Python/program-5/factorial.py rename Python/program-5/{pattern.py => pragram.py} (100%) delete mode 100644 Python/program-6/pattern.py rename Python/program-7/{pattern3.py => program.py} (100%) rename Python/program-8/{pattern4.py => program.py} (100%) rename Python/{program-10/armstrong.py => program-9/program.py} (100%) diff --git a/Python/Program-3/README.md b/Python/Program-3/README.md deleted file mode 100644 index 67521f30..00000000 --- a/Python/Program-3/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Program 3 - -Write a program to check whether the string is palindrome or not - -Variable description-- -a=Holds the input string -b=Holds the reverse of the string diff --git a/Python/README.md b/Python/README.md new file mode 100644 index 00000000..af56595a --- /dev/null +++ b/Python/README.md @@ -0,0 +1,24 @@ +# Python-basicprograms +## This repo contains basics programs in Python programming language. +| Program No.| Question | +| ------- | ------ | +| Program-01 | Program to print Hello World. | +| Program-02 | Program to find the factorial of a number. | +| Program-03 | Program to find if the string is Palindrom or not. | +| Program-04 | Program to find sum of two numbers. | +| Program-05 | Program to print a pattern. | +| Program-06 | Program to print a pattern. | +| Program-07 | Program to print a pattern. | +| Program-08 | Program to print a pattern. | +| Program-09 | Program to check if he number is armstrong or not. | +| Program-10 | Program to shuffle a deck of cards. | +| Program-11 | Program to print fibonacci series. | +| Program-12 | Program to check if a number is prime or not. | +| Program-13 | Program to find a number in an array using binary search. | +| Program-14 | Program to find simple interest for given principal amount, time and rate of interest. | +| Program-15 | Program to sort the array and give the time to sort the array. | +| Program-16 | Program to print a right angled triangle. | + + + + diff --git a/Python/program-11/shufflecards.py b/Python/program-10/program.py similarity index 100% rename from Python/program-11/shufflecards.py rename to Python/program-10/program.py diff --git a/Python/program-14/git.py b/Python/program-11/program.py similarity index 100% rename from Python/program-14/git.py rename to Python/program-11/program.py diff --git a/Python/program-15/git1.py b/Python/program-12/program.py similarity index 100% rename from Python/program-15/git1.py rename to Python/program-12/program.py diff --git a/Python/program-16/git2.py b/Python/program-13/program.py similarity index 100% rename from Python/program-16/git2.py rename to Python/program-13/program.py diff --git a/Python/program-16/readme.md b/Python/program-13/readme.md similarity index 100% rename from Python/program-16/readme.md rename to Python/program-13/readme.md diff --git a/Python/program-18/git3.py b/Python/program-14/program.py similarity index 99% rename from Python/program-18/git3.py rename to Python/program-14/program.py index cfbccef5..f1530142 100644 --- a/Python/program-18/git3.py +++ b/Python/program-14/program.py @@ -2,7 +2,6 @@ # for given principal amount, time and # rate of interest. - def simple_interest(p,t,r): print('The principal is', p) print('The time period is', t) diff --git a/Python/program-14/readme.md b/Python/program-14/readme.md deleted file mode 100644 index 53622207..00000000 --- a/Python/program-14/readme.md +++ /dev/null @@ -1 +0,0 @@ -program to print fibonacci series diff --git a/Python/program-4/sorting.py b/Python/program-15/program.py similarity index 100% rename from Python/program-4/sorting.py rename to Python/program-15/program.py diff --git a/Python/program-15/readme.md b/Python/program-15/readme.md deleted file mode 100644 index a089d895..00000000 --- a/Python/program-15/readme.md +++ /dev/null @@ -1 +0,0 @@ -program to check whether a number is prime or not diff --git a/Python/program-4/triangle.py b/Python/program-16/program.py similarity index 96% rename from Python/program-4/triangle.py rename to Python/program-16/program.py index da4902eb..3b38ab45 100644 --- a/Python/program-4/triangle.py +++ b/Python/program-16/program.py @@ -1,4 +1,4 @@ -for i in range(5): - for j in range(i): - print('*', end=' ') +for i in range(5): + for j in range(i): + print('*', end=' ') print() \ No newline at end of file diff --git a/Python/program-18/readme.md b/Python/program-18/readme.md deleted file mode 100644 index 0c0fcc1d..00000000 --- a/Python/program-18/readme.md +++ /dev/null @@ -1 +0,0 @@ -python program for simple interest \ No newline at end of file diff --git a/Python/program-2/program.py b/Python/program-2/program.py index 7df869a1..47edb63b 100644 --- a/Python/program-2/program.py +++ b/Python/program-2/program.py @@ -1 +1,14 @@ -print("Hello, World!") +fact=int(input("input any number")) +# input any number +factorial = 1 +#predefined factorial of 0 +if fact < 0: + print("factorial is not possible") +elif fact == 0: + print("factorial of "+str(fact) +" is "+str(factorial)) +else: + fact1=fact + while(fact>2): + fact-=1 + fact1=fact1*(fact) + print("factorial is "+ str(fact1)) \ No newline at end of file diff --git a/Python/program-4/README.md b/Python/program-4/README.md deleted file mode 100644 index 7137f722..00000000 --- a/Python/program-4/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# triangle.py -# Draws a triangle \ No newline at end of file diff --git a/Python/program-4/Program 4.py b/Python/program-4/program.py similarity index 96% rename from Python/program-4/Program 4.py rename to Python/program-4/program.py index 77c405f9..d31335e3 100644 --- a/Python/program-4/Program 4.py +++ b/Python/program-4/program.py @@ -1,9 +1,9 @@ -# Store input numbers -num1 = input('Enter first number: ') -num2 = input('Enter second number: ') - -# Add two numbers -sum = float(num1) + float(num2) - -# Display the sum -print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) +# Store input numbers +num1 = input('Enter first number: ') +num2 = input('Enter second number: ') + +# Add two numbers +sum = float(num1) + float(num2) + +# Display the sum +print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) diff --git a/Python/program-5/README.md b/Python/program-5/README.md index 669d2d67..99238315 100644 --- a/Python/program-5/README.md +++ b/Python/program-5/README.md @@ -1,7 +1,10 @@ Program 5 -Write a program to find a factorial of a number. +This program gives the following pattern: -Variable description-- -fact= Holds the input number + 1 + 1 2 1 2 + 1 2 3 1 2 3 + 1 2 3 4 1 2 3 4 +1 2 3 4 5 1 2 3 4 5 diff --git a/Python/program-5/factorial.py b/Python/program-5/factorial.py deleted file mode 100644 index 9db2639b..00000000 --- a/Python/program-5/factorial.py +++ /dev/null @@ -1,14 +0,0 @@ -fact=int(input("input any number")) -# input any number -factorial =1 -#predefined factorial of 0 -if fact<0: - print("factorial is not possible") -elif fact==0: - print("factorial of "+str(fact) +" is "+str(factorial)) -else: - fact1=fact - while(fact>2): - fact-=1 - fact1=fact1*(fact) - print("factorial is "+ str(fact1)) \ No newline at end of file diff --git a/Python/program-5/pattern.py b/Python/program-5/pragram.py similarity index 100% rename from Python/program-5/pattern.py rename to Python/program-5/pragram.py diff --git a/Python/program-6/README.md b/Python/program-6/README.md index 8d8c46c6..55a615a3 100644 --- a/Python/program-6/README.md +++ b/Python/program-6/README.md @@ -1,7 +1,10 @@ Program 6 -Write a program to check whether a number is prime or not +The code gives the following pattern : -Variable description-- -n= holds input value +1 +2 2 +3 3 3 +4 4 4 4 +5 5 5 5 5 diff --git a/Python/program-6/pattern.py b/Python/program-6/pattern.py deleted file mode 100644 index 456583e0..00000000 --- a/Python/program-6/pattern.py +++ /dev/null @@ -1,4 +0,0 @@ -for i in range(1,6): - for j in range(1,i+1): - print(i,end=' ') - print() diff --git a/Python/program-6/program.py b/Python/program-6/program.py index 8b70a1d6..456583e0 100644 --- a/Python/program-6/program.py +++ b/Python/program-6/program.py @@ -1,14 +1,4 @@ -n=int(input("enter any number")) -# n is the number to check whether it is prime or not -if n>1: - # loop from 2 to n/2 - for i in range(2,int(n/2)): - - if(n%i)==0: - #if n is completly divisible by i then it is not a prime number - print("n is not prime") - break - else: - print("n is prime") -else: - print("not prime") +for i in range(1,6): + for j in range(1,i+1): + print(i,end=' ') + print() diff --git a/Python/program-7/pattern3.py b/Python/program-7/program.py similarity index 100% rename from Python/program-7/pattern3.py rename to Python/program-7/program.py diff --git a/Python/program-8/pattern4.py b/Python/program-8/program.py similarity index 100% rename from Python/program-8/pattern4.py rename to Python/program-8/program.py diff --git a/Python/program-10/armstrong.py b/Python/program-9/program.py similarity index 100% rename from Python/program-10/armstrong.py rename to Python/program-9/program.py From 21f7a694f37e4abde76e74aa1f1561ca61e4e782 Mon Sep 17 00:00:00 2001 From: RachithaRai Date: Tue, 6 Oct 2020 23:22:20 +0530 Subject: [PATCH 14/36] Update readme --- readme.md | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 17b64228..a635edd2 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,118 @@ -

Basic Program

- +

Basic Program

-## This repo contains basics programs in all languages. -## Contribution -If you want to contribute to this repo then [click here](https://github.com/swaaz/basicprograms/blob/swaaz/.github/ISSUE_TEMPLATE/contribution.md) +## This repo is an awesome collection of basic programs in different programming languages⚡ +
+ + + + + + + +

+ +## ⚠️Points to note before you start contributing +- Check whether the program you are going to add already exists in the repo or not. Make sure you're not repeting any program. +- Please go through [How to contribute](#contribute) and do accordingly to make a smooth contribution. +

+ +## Folder structure: +``` +. +├── C++ +│ ├── Program-1 +│ │ ├── program.cpp +│ │ ├── readme.md +│ . . +│ . . +│ +├── C +│ ├── Program-1 +│ │ ├── program.c +│ │ ├── readme.md +│ . . +│ . . +│ +├── Java +│ ├── Program-1 +│ │ ├── program.java +│ │ ├── readme.md +│ . . +│ . . +│ +├── Javascript +│ ├── Program-1 +│ │ ├── program.js +│ │ ├── readme.md +│ . . +│ . . +│ +├── Python +│ ├── Program-1 +│ │ ├── program.py +│ │ ├── readme.md +│ . . +│ . . +│ +``` +

+ +# How to contribute + + +- Fork this [repo](https://github.com/swaaz/basicprograms) + +- Clone it using command : +
 $ git clone paste_the_copied_url.
+ +- Open folder "basicprograms" : +
$ cd basicprograms
+ +- Open folder "C/Python" : +
$ cd folder_name
+ eg: cd C + +- Create new branch : +
 $ git branch new_branch_name
+ eg: git branch hactoberfest + +- Checkout to new branch from master branch : +
$ git checkout new_branch_name
+ eg: git checkout hactoberfest + + - Create a new folder +
 $ mkdir program-number 
+ eg: mkdir program-35 + + - Change directory to the new created folder +
 $ cd folder_name 
+ + - Create a file *program.c* + + - Write the code inside program.c file + ### NOTE: Before writng code refer [*sample*](https://github.com/swaaz/basicprograms/blob/swaaz/C/sample.c) file and write the code in the same format as given + + - Add file : +
$ git add -A
+ +- Commit file : +
$ git commit -m "comment"
+ eg: git commit -m "program added" + +- Push the file : +
$ git push origin -u 'branch_name'
+ eg: git push origin -u hactoberfest + +- The given link should be copied and pasted in web browser or go to your repo in web browser + +- Create a pull request + +- tag @swaaz under review section

+ +### Tada you just made a contribution ✨. Pat your back 👏

+ +### If you have never made a PR before 😕, no worries, follow these steps to get going [👉click me](https://gitme.js.org/) + From 69f8d3ef282fb7287d6af61be75c7790ac0025bc Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Tue, 6 Oct 2020 23:35:23 +0530 Subject: [PATCH 15/36] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a635edd2..7ed0e521 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ -## This repo is an awesome collection of basic programs in different programming languages⚡ +## This Repository is an awesome collection of basic programs in different programming languages⚡
From 478f205c5ff757e242d12acdce948dd2823258cc Mon Sep 17 00:00:00 2001 From: Mgeethabhargava Date: Wed, 7 Oct 2020 05:54:32 +0530 Subject: [PATCH 16/36] New javascript programs --- Javascript/program-10/program-10.html | 15 +++++++++++++++ Javascript/program-10/read.md | 4 ++++ Javascript/program-9/program-9.html | 16 ++++++++++++++++ Javascript/program-9/read.md | 4 ++++ 4 files changed, 39 insertions(+) create mode 100644 Javascript/program-10/program-10.html create mode 100644 Javascript/program-10/read.md create mode 100644 Javascript/program-9/program-9.html create mode 100644 Javascript/program-9/read.md diff --git a/Javascript/program-10/program-10.html b/Javascript/program-10/program-10.html new file mode 100644 index 00000000..6213daf3 --- /dev/null +++ b/Javascript/program-10/program-10.html @@ -0,0 +1,15 @@ + + + + +

My First Web Page

+

My First Paragraph.

+ +

+ + + + + \ No newline at end of file diff --git a/Javascript/program-10/read.md b/Javascript/program-10/read.md new file mode 100644 index 00000000..b6ac8af1 --- /dev/null +++ b/Javascript/program-10/read.md @@ -0,0 +1,4 @@ +# Program-10 + +## This is a javascript program for javascript writing into an html element + diff --git a/Javascript/program-9/program-9.html b/Javascript/program-9/program-9.html new file mode 100644 index 00000000..6c8a1d04 --- /dev/null +++ b/Javascript/program-9/program-9.html @@ -0,0 +1,16 @@ + + + + +

My First Web Page

+

My first paragraph.

+ +

Never call document.write after the document has finished loading. +It will overwrite the whole document.

+ + + + + \ No newline at end of file diff --git a/Javascript/program-9/read.md b/Javascript/program-9/read.md new file mode 100644 index 00000000..cb69f65a --- /dev/null +++ b/Javascript/program-9/read.md @@ -0,0 +1,4 @@ +# Program-9 + +## This is a javascript program for javascript writing into html output + From 949677ef134a5221985558b8e13cab4cdf7cc4a8 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:06:38 +0530 Subject: [PATCH 17/36] Rename Python/program-12/pattern.py to Python/program-17/pattern.py --- Python/{program-12 => program-17}/pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Python/{program-12 => program-17}/pattern.py (94%) diff --git a/Python/program-12/pattern.py b/Python/program-17/pattern.py similarity index 94% rename from Python/program-12/pattern.py rename to Python/program-17/pattern.py index e067d825..61155765 100644 --- a/Python/program-12/pattern.py +++ b/Python/program-17/pattern.py @@ -7,4 +7,4 @@ for l in range(1,i+1): print(l,end=" ") print() - \ No newline at end of file + From 44212d8e5b63f3a43a7578392a2a1785dded1913 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:06:55 +0530 Subject: [PATCH 18/36] Rename Python/program-12/readme.md to Python/program-17/readme.md --- Python/{program-12 => program-17}/readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-12 => program-17}/readme.md (100%) diff --git a/Python/program-12/readme.md b/Python/program-17/readme.md similarity index 100% rename from Python/program-12/readme.md rename to Python/program-17/readme.md From 74d2e82a78e5d2898958a94794ac9b55dcaea849 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:07:21 +0530 Subject: [PATCH 19/36] Rename pattern.py to program.py --- Python/program-17/{pattern.py => program.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/program-17/{pattern.py => program.py} (100%) diff --git a/Python/program-17/pattern.py b/Python/program-17/program.py similarity index 100% rename from Python/program-17/pattern.py rename to Python/program-17/program.py From 9b2c3ad6ad35d144d1b577222848ae4e65c1795d Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:07:38 +0530 Subject: [PATCH 20/36] Update readme.md --- Python/program-17/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/program-17/readme.md b/Python/program-17/readme.md index 49831857..bbaed778 100644 --- a/Python/program-17/readme.md +++ b/Python/program-17/readme.md @@ -1,4 +1,4 @@ -PROGRAM-5 +PROGRAM-17 To print the given pattern(pattern.py) 1 1 2 1 2 From b0aa704a1b16e50f923c0f8398d68d328757788c Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:08:00 +0530 Subject: [PATCH 21/36] Rename Python/program-13/readme.md to Python/program-18/readme.md --- Python/{program-13 => program-18}/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Python/{program-13 => program-18}/readme.md (85%) diff --git a/Python/program-13/readme.md b/Python/program-18/readme.md similarity index 85% rename from Python/program-13/readme.md rename to Python/program-18/readme.md index 61af2e38..6da7659a 100644 --- a/Python/program-13/readme.md +++ b/Python/program-18/readme.md @@ -3,4 +3,4 @@ program to print the given pattern 2 2 3 3 3 4 4 4 4 -5 5 5 5 5 \ No newline at end of file +5 5 5 5 5 From 5af3237fae367a5bb73494d9820591ffee060cb0 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:08:23 +0530 Subject: [PATCH 22/36] Rename Python/program-13/pattern2.py to Python/program-18/program.py --- Python/{program-13/pattern2.py => program-18/program.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Python/{program-13/pattern2.py => program-18/program.py} (85%) diff --git a/Python/program-13/pattern2.py b/Python/program-18/program.py similarity index 85% rename from Python/program-13/pattern2.py rename to Python/program-18/program.py index 44eb7a2f..456583e0 100644 --- a/Python/program-13/pattern2.py +++ b/Python/program-18/program.py @@ -1,4 +1,4 @@ for i in range(1,6): for j in range(1,i+1): print(i,end=' ') - print() \ No newline at end of file + print() From 21198e4326da4c75c3f859f8df8067ff98fffc65 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:20:50 +0530 Subject: [PATCH 23/36] Rename Python/program-17/Bitodec.py to Python/program-18/program.py --- Python/{program-17/Bitodec.py => program-18/program.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Python/{program-17/Bitodec.py => program-18/program.py} (92%) diff --git a/Python/program-17/Bitodec.py b/Python/program-18/program.py similarity index 92% rename from Python/program-17/Bitodec.py rename to Python/program-18/program.py index c64a9c0b..80444473 100644 --- a/Python/program-17/Bitodec.py +++ b/Python/program-18/program.py @@ -11,4 +11,4 @@ def decimalToBinary(num): # decimal number number = int(input("Enter any decimal number: ")) -decimalToBinary(number) \ No newline at end of file +decimalToBinary(number) From 2dbc66ff36b88da6359da445c26dc944c5525726 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:21:05 +0530 Subject: [PATCH 24/36] Rename Python/program-17/readme.md to Python/program-18/readme.md --- Python/program-17/readme.md | 1 - Python/program-18/readme.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 Python/program-17/readme.md create mode 100644 Python/program-18/readme.md diff --git a/Python/program-17/readme.md b/Python/program-17/readme.md deleted file mode 100644 index a217e327..00000000 --- a/Python/program-17/readme.md +++ /dev/null @@ -1 +0,0 @@ -Program to convert Binary to Decimal \ No newline at end of file diff --git a/Python/program-18/readme.md b/Python/program-18/readme.md new file mode 100644 index 00000000..28cc94e5 --- /dev/null +++ b/Python/program-18/readme.md @@ -0,0 +1 @@ +Program to convert Binary to Decimal From 112564691d6ee37e74a3ed1954828a1a7d093211 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:22:10 +0530 Subject: [PATCH 25/36] Rename Python/program-18/program.py to Python/program-19/program.py --- Python/{program-18 => program-19}/program.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-18 => program-19}/program.py (100%) diff --git a/Python/program-18/program.py b/Python/program-19/program.py similarity index 100% rename from Python/program-18/program.py rename to Python/program-19/program.py From 2db2b0ef43c82626952a5f6af0940dd0f1ff73b6 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 11:22:28 +0530 Subject: [PATCH 26/36] Rename Python/program-18/readme.md to Python/program-19/readme.md --- Python/{program-18 => program-19}/readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-18 => program-19}/readme.md (100%) diff --git a/Python/program-18/readme.md b/Python/program-19/readme.md similarity index 100% rename from Python/program-18/readme.md rename to Python/program-19/readme.md From 876a80d45de8f19d2bd2430a7251366f11e03eb7 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 12:08:08 +0530 Subject: [PATCH 27/36] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 7ed0e521..0a5ec0fd 100644 --- a/readme.md +++ b/readme.md @@ -16,6 +16,7 @@ ## ⚠️Points to note before you start contributing - Check whether the program you are going to add already exists in the repo or not. Make sure you're not repeting any program. +- Do add readme.md file for explaining the question , input and output for each program. - Please go through [How to contribute](#contribute) and do accordingly to make a smooth contribution.

From 443426fcad08d496781caa1cc5a585305816d8e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Oct 2020 14:26:22 +0530 Subject: [PATCH 28/36] new program --- Python/README.md | 3 ++- Python/program-17/program.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Python/program-17/program.py diff --git a/Python/README.md b/Python/README.md index af56595a..0bd08b85 100644 --- a/Python/README.md +++ b/Python/README.md @@ -10,7 +10,7 @@ | Program-06 | Program to print a pattern. | | Program-07 | Program to print a pattern. | | Program-08 | Program to print a pattern. | -| Program-09 | Program to check if he number is armstrong or not. | +| Program-09 | Program to check if the number is armstrong or not. | | Program-10 | Program to shuffle a deck of cards. | | Program-11 | Program to print fibonacci series. | | Program-12 | Program to check if a number is prime or not. | @@ -18,6 +18,7 @@ | Program-14 | Program to find simple interest for given principal amount, time and rate of interest. | | Program-15 | Program to sort the array and give the time to sort the array. | | Program-16 | Program to print a right angled triangle. | +| Program-17 | Program to check leap year or not. | diff --git a/Python/program-17/program.py b/Python/program-17/program.py new file mode 100644 index 00000000..c843e104 --- /dev/null +++ b/Python/program-17/program.py @@ -0,0 +1,7 @@ + +year = int( input('Enter Year: ')) + +if (year%4) and (year%100) and (year%400) == 0: + print('Leap year') +else: + print('Not leap year') From e8afe45d531a20fcfb60dcd69e253859fd9af64b Mon Sep 17 00:00:00 2001 From: Tanushree Aggarwal <47485195+shreetanu@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:05:38 +0530 Subject: [PATCH 29/36] Program.cpp A program in C++ that finds the Greatest common divisor or Highest common factor of two numbers. --- C++/Program-6/program.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C++/Program-6/program.cpp diff --git a/C++/Program-6/program.cpp b/C++/Program-6/program.cpp new file mode 100644 index 00000000..23a755c2 --- /dev/null +++ b/C++/Program-6/program.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int gcd(int x,int y) +{ + if(y==0) + return x; + return gcd(y,x%y); +} + +int main() { + cout<<"enter the numbers\n"; + int x,y; + cin>>x>>y; + cout<<"The GCD is "< Date: Wed, 7 Oct 2020 16:10:20 +0530 Subject: [PATCH 30/36] Readme.md --- C++/Program-6/Readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 C++/Program-6/Readme.md diff --git a/C++/Program-6/Readme.md b/C++/Program-6/Readme.md new file mode 100644 index 00000000..00f303b9 --- /dev/null +++ b/C++/Program-6/Readme.md @@ -0,0 +1,10 @@ +Program 6 + +Write a program to find the greatest common divisor of two number. + +Variable description-- + +x=Holds the first number + +y=Holds the second number + From 9214b3b9bfbfb6fb604b1dde741403a3153863bd Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:20:40 +0530 Subject: [PATCH 31/36] Rename Python/program-17/program.py to Python/program-18/program.py --- Python/{program-17 => program-18}/program.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-17 => program-18}/program.py (100%) diff --git a/Python/program-17/program.py b/Python/program-18/program.py similarity index 100% rename from Python/program-17/program.py rename to Python/program-18/program.py From d33b8c94cb7de3a2f436d831008ad5924ec34b25 Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:21:08 +0530 Subject: [PATCH 32/36] Rename Python/program-18/program.py to Python/program-19/program.py --- Python/{program-18 => program-19}/program.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-18 => program-19}/program.py (100%) diff --git a/Python/program-18/program.py b/Python/program-19/program.py similarity index 100% rename from Python/program-18/program.py rename to Python/program-19/program.py From d45d9e7179cbb117f0d73b0f0d0420ba29d8d65b Mon Sep 17 00:00:00 2001 From: Swasthik Shetty <42874695+swaaz@users.noreply.github.com> Date: Wed, 7 Oct 2020 16:21:28 +0530 Subject: [PATCH 33/36] Rename Python/program-19/program.py to Python/program-20/program.py --- Python/{program-19 => program-20}/program.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/{program-19 => program-20}/program.py (100%) diff --git a/Python/program-19/program.py b/Python/program-20/program.py similarity index 100% rename from Python/program-19/program.py rename to Python/program-20/program.py From 035a6f43d788d7f2488d763a1ac5b4db46d0f751 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Oct 2020 19:21:40 +0530 Subject: [PATCH 34/36] Updated README.md --- C/program-61/program.c | 77 ++++++++++++++++++++++++++---------- Python/README.md | 3 +- Python/program-17/program.py | 24 ++++++----- Python/program-17/readme.md | 7 ---- Python/program-18/program.py | 11 ++++-- Python/program-18/readme.md | 6 --- Python/program-19/program.py | 14 ------- Python/program-19/readme.md | 1 - Python/program-20/program.py | 7 ---- 9 files changed, 79 insertions(+), 71 deletions(-) delete mode 100644 Python/program-17/readme.md delete mode 100644 Python/program-18/readme.md delete mode 100644 Python/program-19/program.py delete mode 100644 Python/program-19/readme.md delete mode 100644 Python/program-20/program.py diff --git a/C/program-61/program.c b/C/program-61/program.c index 0bfbf2dc..ca8f1a80 100644 --- a/C/program-61/program.c +++ b/C/program-61/program.c @@ -1,23 +1,58 @@ -#include -void main() +/* + This Program calulates all the prime between the range of numbers + includes the numbers which is provided. + + For e.g: 2 7 + Prime Numbers are : 2 3 5 7 +*/ + +#include +#include + +char primecheck(int); + +int main() { - double r,area,circum;//Initializing varaibles - - printf("Enter Radius:"); - scanf("%lf",&r);//getting radius. - - if(r<10)//Checks if radius is less than 10 - { - circum = 2*3.14*r;//Circumference of a circle is 2*pi*r. - - printf("The Circumference of the Circle with the given radius is: %lf",circum);//printing Circumference - } - else//If r is NOT less that 10....i.e. r is greater than 10 - { - area = 3.14*r*r;//Area of a circle is pi*r*r. - - printf("The Area of the Circle with the given radius is: %lf",area);//printing The area - } - getch(); - + int i,num1,num2,cases; + char ans; + printf("Enter Number of Test Cases: "); + scanf("%d",&cases); + while (cases--) + { + printf("Enter First Number: "); + scanf("%d",&num1); + printf("Enter Second Number: "); + scanf("%d",&num2); + + printf("Answer: "); + for(i=num1;i<=num2;i++) + { + ans = primecheck(i); + if (ans == 'y') + printf("%d ",i); + } + printf("\n"); + } + return 0; } + +char primecheck(int num) +{ + int i; + if (num == 0 || num == 1) + return 'n'; + else + { + for(i=(num-1);i>1;i--) + { + if(num%i == 0) + { + return 'n'; + } + else + continue; + } + return 'y'; + } + +} \ No newline at end of file diff --git a/Python/README.md b/Python/README.md index 0bd08b85..fa05a6c4 100644 --- a/Python/README.md +++ b/Python/README.md @@ -18,7 +18,8 @@ | Program-14 | Program to find simple interest for given principal amount, time and rate of interest. | | Program-15 | Program to sort the array and give the time to sort the array. | | Program-16 | Program to print a right angled triangle. | -| Program-17 | Program to check leap year or not. | +| Program-17 | Program to convert Binary to Decimal. | +| Program-18 | Program to check leap year or not. | diff --git a/Python/program-17/program.py b/Python/program-17/program.py index 61155765..80444473 100644 --- a/Python/program-17/program.py +++ b/Python/program-17/program.py @@ -1,10 +1,14 @@ -for i in range(1,6): - for j in range(1,6-i): - print(" ",end=" ") - for k in range(1,i+1): - print(k,end=" ") - if i>1: - for l in range(1,i+1): - print(l,end=" ") - print() - +#Python Program to Convert Decimal to Binary + +def decimalToBinary(num): + """This function converts decimal number + to binary and prints it""" + if num > 1: + decimalToBinary(num // 2) + print(num % 2, end='') + + +# decimal number +number = int(input("Enter any decimal number: ")) + +decimalToBinary(number) diff --git a/Python/program-17/readme.md b/Python/program-17/readme.md deleted file mode 100644 index bbaed778..00000000 --- a/Python/program-17/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -PROGRAM-17 -To print the given pattern(pattern.py) - 1 - 1 2 1 2 - 1 2 3 1 2 3 - 1 2 3 4 1 2 3 4 -1 2 3 4 5 1 2 3 4 5 diff --git a/Python/program-18/program.py b/Python/program-18/program.py index 456583e0..c843e104 100644 --- a/Python/program-18/program.py +++ b/Python/program-18/program.py @@ -1,4 +1,7 @@ -for i in range(1,6): - for j in range(1,i+1): - print(i,end=' ') - print() + +year = int( input('Enter Year: ')) + +if (year%4) and (year%100) and (year%400) == 0: + print('Leap year') +else: + print('Not leap year') diff --git a/Python/program-18/readme.md b/Python/program-18/readme.md deleted file mode 100644 index 6da7659a..00000000 --- a/Python/program-18/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -program to print the given pattern -1 -2 2 -3 3 3 -4 4 4 4 -5 5 5 5 5 diff --git a/Python/program-19/program.py b/Python/program-19/program.py deleted file mode 100644 index 80444473..00000000 --- a/Python/program-19/program.py +++ /dev/null @@ -1,14 +0,0 @@ -#Python Program to Convert Decimal to Binary - -def decimalToBinary(num): - """This function converts decimal number - to binary and prints it""" - if num > 1: - decimalToBinary(num // 2) - print(num % 2, end='') - - -# decimal number -number = int(input("Enter any decimal number: ")) - -decimalToBinary(number) diff --git a/Python/program-19/readme.md b/Python/program-19/readme.md deleted file mode 100644 index 28cc94e5..00000000 --- a/Python/program-19/readme.md +++ /dev/null @@ -1 +0,0 @@ -Program to convert Binary to Decimal diff --git a/Python/program-20/program.py b/Python/program-20/program.py deleted file mode 100644 index c843e104..00000000 --- a/Python/program-20/program.py +++ /dev/null @@ -1,7 +0,0 @@ - -year = int( input('Enter Year: ')) - -if (year%4) and (year%100) and (year%400) == 0: - print('Leap year') -else: - print('Not leap year') From bb8a8ac70b6f4ea6b0eaee102e2c9b187a708dc3 Mon Sep 17 00:00:00 2001 From: RachithaRai Date: Wed, 7 Oct 2020 20:40:28 +0530 Subject: [PATCH 35/36] add program --- C++/Program-7/program.cpp | 29 +++++++++++++++++++++++++++++ C++/Program-7/readme.md | 1 + 2 files changed, 30 insertions(+) create mode 100644 C++/Program-7/program.cpp create mode 100644 C++/Program-7/readme.md diff --git a/C++/Program-7/program.cpp b/C++/Program-7/program.cpp new file mode 100644 index 00000000..eacc83aa --- /dev/null +++ b/C++/Program-7/program.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() +{ + int rows, n = 1; + + cout << "Enter number of rows: \n"; + cin >> rows; + + for(int i = 0; i < rows; i++) + { + for(int line = 1; line <= rows-i; line++) + cout <<" "; + + for(int j = 0; j <= i; j++) + { + if (j == 0 || i == 0) + n = 1; + else + n = n*(i-j+1)/j; + + cout << n << " "; + } + cout << endl; + } + + return 0; +} \ No newline at end of file diff --git a/C++/Program-7/readme.md b/C++/Program-7/readme.md new file mode 100644 index 00000000..83bd1a5b --- /dev/null +++ b/C++/Program-7/readme.md @@ -0,0 +1 @@ +C++ Program to print Pascal' triangle \ No newline at end of file From c813101bfa213f7ab9d9d14e362858c6e7495795 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Oct 2020 00:15:20 +0530 Subject: [PATCH 36/36] Added new programs --- Python/README.md | 6 ++---- Python/program-19/program.py | 10 ++++++++++ Python/program-20/program.py | 9 +++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 Python/program-19/program.py create mode 100644 Python/program-20/program.py diff --git a/Python/README.md b/Python/README.md index fa05a6c4..c1b29aee 100644 --- a/Python/README.md +++ b/Python/README.md @@ -20,7 +20,5 @@ | Program-16 | Program to print a right angled triangle. | | Program-17 | Program to convert Binary to Decimal. | | Program-18 | Program to check leap year or not. | - - - - +| Program-19 | Program to count number of integers between 1 to 50 divisible by a number. | +| Program-20 | Program to create an array of range specified and print. | \ No newline at end of file diff --git a/Python/program-19/program.py b/Python/program-19/program.py new file mode 100644 index 00000000..b7fbc2ee --- /dev/null +++ b/Python/program-19/program.py @@ -0,0 +1,10 @@ +a = int(input()) +count = 0 +list_1 = [i for i in range(1, 51)] + +for i in list_1: + if i != a: + if i%a == 0: + count+=1 + +print(count,end='') \ No newline at end of file diff --git a/Python/program-20/program.py b/Python/program-20/program.py new file mode 100644 index 00000000..c01b73a1 --- /dev/null +++ b/Python/program-20/program.py @@ -0,0 +1,9 @@ +a,b = input().split() + +a = int(a) +b = int(b) + +list_1 = list(x for x in range(a+1,b+1)) + +for i in list_1[a:b]: + print(i) \ No newline at end of file