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 + 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