0) {
20 |
21 | // Step 1: Find remainder
22 | int r = square % 10;
23 |
24 | // Add remainder to the current sum
25 | sum += r;
26 |
27 | // Drop last digit of the product
28 | // and store the number
29 | square = square / 10;
30 | }
31 |
32 | // Condition check
33 | // Sum of digits of number obtained is
34 | // equal to original number
35 | if (sum == n)
36 |
37 | // number is neon
38 | return true;
39 | else
40 |
41 | // numbe is not neon
42 | return false;
43 | }
44 |
45 | // Main driver method
46 | public static void main(String[] args)
47 | {
48 | // Custom input
49 | int n = 9;
50 |
51 | // Calling above function to check custom number or
52 | // if user entered number via Scanner class
53 | if (checkNeon(n))
54 |
55 | // Print number considered is neon
56 | System.out.println("Given number " + n
57 | + " is Neon number");
58 | else
59 |
60 | // Print number considered is not neon
61 | System.out.println("Given number " + n
62 | + " is not a Neon number");
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Javascript/program - 16/program-16.js:
--------------------------------------------------------------------------------
1 | let n = 5;
2 | let string = "";
3 | // Upside pyramid
4 | // upside diamond
5 | for (let i = 1; i <= n; i++) {
6 | // printing spaces
7 | for (let j = n; j > i; j--) {
8 | string += " ";
9 | }
10 | // printing star
11 | for (let k = 0; k < i * 2 - 1; k++) {
12 | if (k === 0 || k === 2 * i - 2) {
13 | string += "*";
14 | }
15 | else {
16 | string += " ";
17 | }
18 | }
19 | string += "\n";
20 | }
21 | // downside diamond
22 | for (let i = 1; i <= n - 1; i++) {
23 | // printing spaces
24 | for (let j = 0; j < i; j++) {
25 | string += " ";
26 | }
27 | // printing star
28 | for (let k = (n - i) * 2 - 1; k >= 1; k--) {
29 | if (k === 1 || k === (n - i) * 2 - 1) {
30 | string += "*";
31 | }
32 | else {
33 | string += " ";
34 | }
35 | }
36 | string += "\n";
37 | }
38 | console.log(string);
39 |
--------------------------------------------------------------------------------
/Javascript/program - 16/read.md:
--------------------------------------------------------------------------------
1 | # Program-16
2 | ## Program to print hollow diamond
--------------------------------------------------------------------------------
/Javascript/program- 17/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Javascript/program- 17/sketch.js:
--------------------------------------------------------------------------------
1 | let cart = [];
2 | let wishlist = [];
3 |
4 | cart.push({name:"Notebook",price:50,brand:"Classmate"});
5 | cart.push({name:"Laptop",price:40000,brand:"Dell"});
6 | cart.push({name:"Mouse",price:700,brand:"Dell"});
7 |
8 | wishlist.push({name:"Pen",price:500,brand:"Parker"});
9 | wishlist.push({name:"Watch",price:2000,brand:"Titan"});
10 | wishlist.push({name:"Mobile",price:50000,brand:"Apple"});
11 |
12 | cart.pop();
13 | console.log(cart);
14 | console.log("There are "+cart.length +" items in cart");
15 | console.log(wishlist);
16 | console.log("There are "+wishlist.length +" items in cart");
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Javascript/program- 17/style.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 | canvas {
6 | display: block;
7 | }
8 |
--------------------------------------------------------------------------------
/Javascript/program-1/program-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SUM OF THE TWO NUMBERS
4 |
13 |
14 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Javascript/program-1/read.md:
--------------------------------------------------------------------------------
1 | # Program-1
2 | ## This is a javascript program for adding two numbers
3 |
--------------------------------------------------------------------------------
/Javascript/program-10/program-10.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | My First Web Page
6 | My First Paragraph.
7 |
8 |
9 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Javascript/program-10/read.md:
--------------------------------------------------------------------------------
1 | # Program-10
2 |
3 | ## This is a javascript program for javascript writing into an html element
4 |
5 |
--------------------------------------------------------------------------------
/Javascript/program-11/program.js:
--------------------------------------------------------------------------------
1 | const isIsogram = str => {
2 | str = str.toLowerCase();
3 | for (let i=0 ; str.length > i ; i++){
4 | for(let j=1+i ; str.length > j ; j++ ){
5 | if ( str[i]==str[j] ){
6 | return false;
7 | }
8 | }
9 | }
10 | return true;
11 | }
12 |
13 | //isIsogram('isogram'); // true
14 | //isIsogram('isIsogram'); // false
--------------------------------------------------------------------------------
/Javascript/program-11/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: isIsogram
3 | tags: string,begginer
4 | ---
5 |
6 | Checks if a given word is an isogram or not. An isogram is a word that has no repeating letters.
7 |
8 | - Convert string to `lowercase`/`uppercase` since capital letters do not equate to small letter.
9 | - Iterate the string using 2 for loops using the iterators `i` and `j`. Where `j` starts of 1 more than `i`.
10 | - If at any point `str[i]` is equal to `str[j]` return `false`.
11 | - If the above does not happen till you reach the end of the string return `true`.
12 |
--------------------------------------------------------------------------------
/Javascript/program-12/program.js:
--------------------------------------------------------------------------------
1 | // string concatenation
2 | let a = 2 + 2 + '1';
3 | console.log(a); // 41
4 |
5 |
6 | let b = '1' + 2 + 2;
7 | console.log(b); // 122
8 |
9 | // unary conversion using +
10 | let c = "";
11 | console.log(+c); // 0
12 |
13 |
14 | let val1 = "2";
15 | let val2 = "3";
16 | console.log(+val1 + +val2); // 5
17 |
18 | console.log(+false);
19 |
20 |
21 | // chaining assignment
22 | let x,y,z;
23 | x = y = z = 5;
24 | console.log(x,y,z); // 5 5 5
25 |
26 | // increment/decrement
27 | let counter = 5;
28 | console.log(++counter); // 6
29 | console.log(counter++); //6
30 | console.log(counter); //7
31 | console.log(--counter); // 6
32 | console.log(counter--); //6
33 | console.log(counter); //5
34 |
35 |
36 | //comma operators
37 | let comma = (1+2, 3+4);
38 | console.log(comma); // 7 (returns only the last result)
39 |
40 | let sym1 = Symbol("id");
41 | let sym2 = Symbol.for("id"); // if doesn't exist creats new one
42 |
43 | let str = "Hello \rworls";
44 | console.log(str)
45 |
46 |
47 | // Example to find common elements between 2 arrays.
48 | let ar1 = [1,2,3,4,5];
49 | let ar2 = [4,5,6];
50 |
51 | let ar = ar1.filter(function(val) {
52 | for(let ke of this) {
53 | if (val == ke)
54 | return true;
55 | }
56 | }, ar2);
57 |
58 | console.log( ar );
--------------------------------------------------------------------------------
/Javascript/program-13/program.js:
--------------------------------------------------------------------------------
1 | `Asyncronous function
2 | async function executes after the main thread is done with execution`
3 |
4 | console.log("first");
5 |
6 | async function fun() {
7 | let promise = new Promise((resolve, reject) => {
8 | setTimeout(() => resolve("Executed this!"), 2000);
9 | });
10 |
11 | let result = await promise;
12 | console.log(result);
13 | };
14 |
15 | fun();
16 |
17 | console.log("first");
18 |
--------------------------------------------------------------------------------
/Javascript/program-14/program.js:
--------------------------------------------------------------------------------
1 | `Constructor Functions
2 | * Create multiple objects with same body using a constructor function`
3 |
4 | function Person(name, age){
5 | this.name = name;
6 | this.age = age;
7 | this.greeting = function() {
8 | console.log(`hi ${name}`);
9 | }
10 | }
11 |
12 |
13 | // defining methods outside the constructor
14 | Person.hey = function() {console.log("hello")};
15 | Person.hey();
16 | Person.prototype.welcome = function() {
17 | console.log(`welcom ${this.name}`);
18 | }
19 |
20 |
21 | let obj = new Person('abc', 21);
22 | obj.gender = function(gen) {
23 | console.log(this.name, gen);
24 | };
25 | obj.gender("male");
26 | console.log(obj);
27 | console.log(obj["name"]);
28 | console.log(obj.age);
29 | obj.greeting();
30 | obj.welcome();
31 |
32 |
33 | function Human(name, age, gender) {
34 | Person.call(this, name, age);
35 | this.gender = gender;
36 | this.greet = function() {
37 | console.log(`hello ${this.name}`);
38 | }
39 | }
40 |
41 | let obj2 = new Human('abc', 21, "male");
42 | console.log(obj);
43 | let obj3 = new Human('abcd', 22, "female");
44 | console.log(obj2);
45 |
46 | let test1 = {
47 | string: "hey",
48 | }
49 | let test2 = {
50 | number: 50,
51 | }
52 |
53 | // copying objects
54 | Object.assign(test1, test2);
55 | test2.number = 60;
56 | console.log(test1);
57 | console.log(test2);
58 |
59 | console.log('test' in test1);
60 |
61 | // obj2.greet();
62 | // obj2.greeting();
63 | // obj3.greeting();
64 |
65 | // console.log("name" in obj);
66 |
67 | function a() {
68 | console.log("12");
69 | return function() {
70 | return 1;
71 | }
72 | }
73 | let b = a();
74 | console.log(b);
--------------------------------------------------------------------------------
/Javascript/program-15/program.js:
--------------------------------------------------------------------------------
1 | `class is the blurprint used for object creation.
2 | * class B inherits properties and methods from parent class A.
3 | * And Class B overwrites fun() method.`
4 |
5 | class A {
6 | constructor (name, age) {
7 | this.name = name;
8 | this.age = age;
9 | }
10 | fun() {
11 | console.log(`Saying hello to ${this.name}`);
12 | }
13 | }
14 |
15 |
16 | class B extends A {
17 | constructor (name, age, gender) {
18 | super(name, age);
19 | this.gender = gender;
20 | // this.fun();
21 | }
22 | fun() {
23 | console.log(`Saying hello to ${this.name} from B`);
24 | }
25 | fun2() {
26 | console.log(`Saying hello to ${this.name} from B fun 2`);
27 | }
28 | }
29 |
30 |
31 | class C extends B {
32 | constructor (name, age, gender, section) {
33 | super(name, age, gender);
34 | // this.name = "fixed";
35 | this.section = section;
36 | }
37 | fun() {
38 | console.log(`Saying hello to ${this.name} from C`);
39 | }
40 | }
41 |
42 |
43 | let instance = new A("demo", 20);
44 | let instance1 = new B("demo", 20, "male");
45 | let instance2 = new C("Cclass", 11, "abc", "c");
46 |
47 | console.log(instance1.name);
48 | console.log(instance1.gender);
49 | instance1.fun();
50 |
51 | console.log(instance2.name);
52 | console.log(instance2.gender);
53 | instance2.fun();
54 | instance2.fun2();
55 |
56 |
57 | console.log(A.prototype);
--------------------------------------------------------------------------------
/Javascript/program-16/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Get Data
8 |
9 |
10 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Javascript/program-16/readme.md:
--------------------------------------------------------------------------------
1 | # Program 16
2 |
3 | Retrieve data from HTML form and validate it
4 |
--------------------------------------------------------------------------------
/Javascript/program-2/program-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CHARACTER PROCESSING METHODS
4 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Javascript/program-2/read.md:
--------------------------------------------------------------------------------
1 | # Program-2
2 | ## This is a javascript program for string operations
3 |
--------------------------------------------------------------------------------
/Javascript/program-3/program-3.html:
--------------------------------------------------------------------------------
1 |
2 | ARMSTRONG NUMBER
3 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Javascript/program-3/read.md:
--------------------------------------------------------------------------------
1 | # Program-3
2 | ## This is a javascript program for armstrong
3 |
4 |
--------------------------------------------------------------------------------
/Javascript/program-4/program-4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Check Palindrome with JavaScript Program
5 |
10 |
48 |
49 |
50 |
54 |
55 |
--------------------------------------------------------------------------------
/Javascript/program-4/read.md:
--------------------------------------------------------------------------------
1 | # Program-4
2 | ## This is a javascript program for palindrome
3 |
4 |
--------------------------------------------------------------------------------
/Javascript/program-5/program-5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | MATHEMATICAL OPERATIONS OF TWO NUMBERS
4 |
34 |
35 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Javascript/program-5/read.md:
--------------------------------------------------------------------------------
1 | # Program-5
2 | ## This is a javascript program for mathematical operations
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Javascript/program-6/program-6.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CHARACTER PROCESSING METHODS
4 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Javascript/program-6/read.md:
--------------------------------------------------------------------------------
1 | # Program-6
2 | ## This is a javascript program for character processing
3 |
4 |
--------------------------------------------------------------------------------
/Javascript/program-7/program-7.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Searching strings with index Of amd LastIndex of
4 |
5 |
16 |
17 |
18 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Javascript/program-7/program.js:
--------------------------------------------------------------------------------
1 | // program to sort words in alphabetical order
2 |
3 | // take input
4 | const string = prompt('Enter a sentence: ');
5 |
6 | // converting to an array
7 | const words = string.split(' ');
8 |
9 | // sort the array elements
10 | words.sort();
11 |
12 | // display the sorted words
13 | console.log('The sorted words are:');
14 |
15 | for (const element of words) {
16 | console.log(element);
17 | }
--------------------------------------------------------------------------------
/Javascript/program-7/read.md:
--------------------------------------------------------------------------------
1 | # Program-7
2 |
3 | ## This is a javascript program for string searching
4 |
5 |
--------------------------------------------------------------------------------
/Javascript/program-8/program-8.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 | When you click "Try it", a function will be called.
14 | The function will display a message.
15 |
16 | Try it
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Javascript/program-8/read.md:
--------------------------------------------------------------------------------
1 | # Program-8
2 |
3 | ## This is a javascript program for javascript function basic program
4 |
5 |
--------------------------------------------------------------------------------
/Javascript/program-9/program-9.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | My First Web Page
6 | My first paragraph.
7 |
8 | Never call document.write after the document has finished loading.
9 | It will overwrite the whole document.
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Javascript/program-9/read.md:
--------------------------------------------------------------------------------
1 | # Program-9
2 |
3 | ## This is a javascript program for javascript writing into html output
4 |
5 |
--------------------------------------------------------------------------------
/Program-28/Bin Packing Problem.cpp:
--------------------------------------------------------------------------------
1 | // C++ program to find number of bins required using
2 | // next fit algorithm.
3 | #include
4 | using namespace std;
5 |
6 | // Returns number of bins required using next fit
7 | // online algorithm
8 | int nextFit(int weight[], int n, int c)
9 | {
10 | // Initialize result (Count of bins) and remaining
11 | // capacity in current bin.
12 | int res = 0, bin_rem = c;
13 |
14 | // Place items one by one
15 | for (int i = 0; i < n; i++) {
16 | // If this item can't fit in current bin
17 | if (weight[i] > bin_rem) {
18 | res++; // Use a new bin
19 | bin_rem = c - weight[i];
20 | }
21 | else
22 | bin_rem -= weight[i];
23 | }
24 | return res;
25 | }
26 |
27 | // Driver program
28 | int main()
29 | {
30 | int weight[] = { 2, 5, 4, 7, 1, 3, 8 };
31 | int c = 10;
32 | int n = sizeof(weight) / sizeof(weight[0]);
33 | cout << "Number of bins required in Next Fit : "
34 | << nextFit(weight, n, c);
35 | return 0;
36 | }
37 |
--------------------------------------------------------------------------------
/Program-28/Readme.md:
--------------------------------------------------------------------------------
1 | Given n items of different weights and bins each of capacity c, assign each item to a bin such that number of total used bins is minimized. It may be assumed that all items have weights smaller than bin capacity.
2 |
3 |
4 | Example:
5 | Input: weight[] = {4, 8, 1, 4, 2, 1}
6 | Bin Capacity c = 10
7 | Output: 2
8 | We need minimum 2 bins to accommodate all items
9 | First bin contains {4, 4, 2} and second bin {8, 1, 1}
10 |
11 | Input: weight[] = {9, 8, 2, 2, 5, 4}
12 | Bin Capacity c = 10
13 | Output: 4
14 | We need minimum 4 bins to accommodate all items.
15 |
16 | Input: weight[] = {2, 5, 4, 7, 1, 3, 8};
17 | Bin Capacity c = 10
18 | Output: 3
--------------------------------------------------------------------------------
/Python/Program 35/readme.md:
--------------------------------------------------------------------------------
1 | Python program to search an element in a Circular Linked List
--------------------------------------------------------------------------------
/Python/Program 42/program42.py:
--------------------------------------------------------------------------------
1 | def pattern(n):
2 | k = n - 2
3 | for i in range(n, -1 , -1):
4 | for j in range(k , 0 , -1):
5 | print(end=" ")
6 | k = k + 1
7 | for j in range(0, i+1):
8 | print("* " , end="")
9 | print("\r")
10 | k = 2 * n - 2
11 | for i in range(0 , n+1):
12 | for j in range(0 , k):
13 | print(end="")
14 | k = k - 1
15 | for j in range(0, i + 1):
16 | print("* ", end="")
17 | print("\r")
18 |
19 | pattern(5)
--------------------------------------------------------------------------------
/Python/Program 42/readme.md:
--------------------------------------------------------------------------------
1 | Python program to print Hourglass pattern
--------------------------------------------------------------------------------
/Python/Program 48/Find_area _of_triangle.py:
--------------------------------------------------------------------------------
1 | a = float(input('Enter first side: '))
2 | b = float(input('Enter second side: '))
3 | c = float(input('Enter third side: '))
4 |
5 | s = (a + b + c) / 2
6 |
7 | area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
8 | print('The area of the triangle is:', area)
9 |
--------------------------------------------------------------------------------
/Python/Program-21/Program 21.py.txt:
--------------------------------------------------------------------------------
1 | number = input("Enter the number to be converted to *: ")
2 | for item in number:
3 | print('*' * int(item))
--------------------------------------------------------------------------------
/Python/Program-21/README.md.txt:
--------------------------------------------------------------------------------
1 | This program is to print the number of *. Example if user enter 5. Then it'll print *****
2 |
3 |
--------------------------------------------------------------------------------
/Python/Program-22/Program 22.py.txt:
--------------------------------------------------------------------------------
1 | number = int(input("Enter a number: "))
2 | if (number%2 == 0):
3 | print("the given number is an even number>")
4 |
5 | elif(number%3==0) :
6 | print("The number is an odd number")
7 |
8 | else:
9 | print("It is neither odd nor even number")
--------------------------------------------------------------------------------
/Python/Program-22/README.md:
--------------------------------------------------------------------------------
1 | # This program Plots graph for any function.
2 |
--------------------------------------------------------------------------------
/Python/Program-22/README.md.txt:
--------------------------------------------------------------------------------
1 | Program to check if a number is even or odd
--------------------------------------------------------------------------------
/Python/Program-23/Program 23.py.txt:
--------------------------------------------------------------------------------
1 | start = int(input("Enter the Starting Range: "))
2 | end = int(input("Enter the End Range: "))
3 | print("prime numbers in the range",start,"to",end)
4 | for i in range( start, end+1 ):
5 | flag = 0
6 | for j in range(2 , i):
7 | if (i % j == 0):
8 | flag = 1
9 | break
10 |
11 | if (flag == 0):
12 | print( i , end = ' ')
--------------------------------------------------------------------------------
/Python/Program-23/README.md.txt:
--------------------------------------------------------------------------------
1 | Program to find the all the prime numbers between the given range.
--------------------------------------------------------------------------------
/Python/Program-24/Program 24.txt:
--------------------------------------------------------------------------------
1 | number = int(input("Enter the number to be converted to decimals: "))
2 |
3 |
4 | sum = 0
5 | i = 0
6 | while number != 0:
7 | rem = number % 10
8 | sum = sum + rem * pow(2,i)
9 | number = int(number/10)
10 | i = i + 1
11 | print("The decimal number is: ",sum)
--------------------------------------------------------------------------------
/Python/Program-24/README.md.txt:
--------------------------------------------------------------------------------
1 | Program to convert binary number to decimal
--------------------------------------------------------------------------------
/Python/Program-25/Program 25.py.txt:
--------------------------------------------------------------------------------
1 | command = ""
2 | started = False
3 | while True:
4 | command = input("> ").lower()
5 | if command == "start":
6 | if started:
7 | print("How many times will you start the car")
8 | else:
9 | started = True
10 | print("Car has started")
11 | elif command == "stop":
12 | if not started :
13 | print("Car has already been stopped")
14 | else:
15 | started = False
16 | print("Car has stopped")
17 |
18 | elif command == "help":
19 | for item in ['Start - To Start the car','Stop - To Stop the car', 'Quit - to Quit']:
20 | print(item)
21 | elif command =="quit":
22 | break
23 |
24 | else :
25 | print("Sorry I dont understand")
--------------------------------------------------------------------------------
/Python/Program-25/README.md.txt:
--------------------------------------------------------------------------------
1 | A program of a car game which shows if the car has started or stopped
--------------------------------------------------------------------------------
/Python/Program-26/Program 26.py.txt:
--------------------------------------------------------------------------------
1 | secret_number = 9
2 | guess_count = 0
3 | guess_limit = 3
4 | while guess_count < guess_limit :
5 | guess = int(input('Guess: '))
6 | guess_count += 1
7 | if guess == secret_number :
8 | print('You Won!')
9 | break
10 | else :
11 | print("Sorry u failed!")
--------------------------------------------------------------------------------
/Python/Program-26/README.md.txt:
--------------------------------------------------------------------------------
1 | a program of a guessing game in which u guess the secret number with a guessing limit of 3 attempts
--------------------------------------------------------------------------------
/Python/Program-27/Program 27.txt:
--------------------------------------------------------------------------------
1 | price = input("What is the price of your house? ")
2 | has_good_credit = False
3 | if has_good_credit:
4 | print("The downpayment is 10%")
5 | down_payment = int(price) * 10/100
6 | print("The downpayment is %s"% down_payment)
7 | else :
8 | print("The downpayment is 20%")
9 | down_payment = int(price) * 20/100
10 | print("The downpayment is %s"% down_payment)
--------------------------------------------------------------------------------
/Python/Program-27/README.md.txt:
--------------------------------------------------------------------------------
1 | A program which tells you the of downpayment of the house is 10% or 20%
2 | depending if the owner has a good credit or not.The price of the house is to be entered in the output
--------------------------------------------------------------------------------
/Python/Program-28/Program 28.txt:
--------------------------------------------------------------------------------
1 | import math
2 | a = int(input("Enter the first number: "))
3 | b = int(input("Enter the second number: "))
4 | print("The GCD of the 2 numbers is: ", math.gcd(a,b))
--------------------------------------------------------------------------------
/Python/Program-28/README.md.txt:
--------------------------------------------------------------------------------
1 | The program to find out the GCD of any 2 given numbers
2 |
--------------------------------------------------------------------------------
/Python/Program-29/Program 29.py:
--------------------------------------------------------------------------------
1 | n = int(input("Enter how many numbers you want in the series: "))
2 | first = 0
3 | second = 1
4 | for i in range(n):
5 | print(first)
6 | temp = first
7 | first = second
8 | second = temp + second
--------------------------------------------------------------------------------
/Python/Program-29/README.md:
--------------------------------------------------------------------------------
1 | A program which will display the fibonacci series
2 |
--------------------------------------------------------------------------------
/Python/Program-3/program.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | a=input()
4 | b=a[::-1] #String is reversed and stored in b
5 | if (a==b): # If a and b both are equal string is Palindrome
6 | print("String is Palindrome")
7 | else:
8 | print("String is not Palindrome")
9 |
--------------------------------------------------------------------------------
/Python/Program-30/README.md:
--------------------------------------------------------------------------------
1 | Program 30
2 |
3 | Program to make a simple calculator
4 |
--------------------------------------------------------------------------------
/Python/Program-30/program.py:
--------------------------------------------------------------------------------
1 | # Program make a simple calculator
2 |
3 | # This function adds two numbers
4 | def add(x, y):
5 | return x + y
6 |
7 | # This function subtracts two numbers
8 | def subtract(x, y):
9 | return x - y
10 |
11 | # This function multiplies two numbers
12 | def multiply(x, y):
13 | return x * y
14 |
15 | # This function divides two numbers
16 | def divide(x, y):
17 | return x / y
18 |
19 |
20 | print("Select operation.")
21 | print("1.Add")
22 | print("2.Subtract")
23 | print("3.Multiply")
24 | print("4.Divide")
25 |
26 | while True:
27 | # Take input from the user
28 | choice = input("Enter choice(1/2/3/4): ")
29 |
30 | # Check if choice is one of the four options
31 | if choice in ('1', '2', '3', '4'):
32 | num1 = float(input("Enter first number: "))
33 | num2 = float(input("Enter second number: "))
34 |
35 | if choice == '1':
36 | print(num1, "+", num2, "=", add(num1, num2))
37 |
38 | elif choice == '2':
39 | print(num1, "-", num2, "=", subtract(num1, num2))
40 |
41 | elif choice == '3':
42 | print(num1, "*", num2, "=", multiply(num1, num2))
43 |
44 | elif choice == '4':
45 | print(num1, "/", num2, "=", divide(num1, num2))
46 | break
47 | else:
48 | print("Invalid Input")
--------------------------------------------------------------------------------
/Python/Program-31/Program 31.py:
--------------------------------------------------------------------------------
1 | for i in range (1001):
2 | num = i
3 | result = 0
4 | n = len(str(i))
5 | while (i != 0) :
6 | digit = i%10
7 | result = result + digit**n
8 | i = i//10
9 | if num == result:
10 | print(num)
--------------------------------------------------------------------------------
/Python/Program-31/README.md:
--------------------------------------------------------------------------------
1 | A program for printing Amstrong numbers
2 |
--------------------------------------------------------------------------------
/Python/Program-33/Program33.py:
--------------------------------------------------------------------------------
1 | # defining a function to calculate HCF
2 | def calculate_hcf(x, y):
3 | # selecting the smaller number
4 | if x > y:
5 | smaller = y
6 | else:
7 | smaller = x
8 | for i in range(1,smaller + 1):
9 | if((x % i == 0) and (y % i == 0)):
10 | hcf = i
11 | return hcf
12 |
13 | # taking input from users
14 | num1 = int(input("Enter first number: "))
15 | num2 = int(input("Enter second number: "))
16 | # printing the result for the users
17 | print("The H.C.F. of", num1,"and", num2,"is", calculate_hcf(num1, num2))
--------------------------------------------------------------------------------
/Python/Program-33/Readme.md:
--------------------------------------------------------------------------------
1 | Program to find HCF
--------------------------------------------------------------------------------
/Python/Program-36/Program-36.py:
--------------------------------------------------------------------------------
1 | #WAP TO REVERSING A LIST IN PYTHON
2 |
3 | #METHOD-01:
4 |
5 | # Reversing a list using reversed()
6 | def Reverse(lst):
7 | return [ele for ele in reversed(lst)]
8 |
9 | # Driver Code
10 | lst = [10, 11, 12, 13, 14, 15]
11 | print(Reverse(lst))
12 |
13 |
14 | #METHOD-02:
15 |
16 | # Reversing a list using reverse()
17 | def Reverse(lst):
18 | lst.reverse()
19 | return lst
20 |
21 | lst = [10, 11, 12, 13, 14, 15]
22 | print(Reverse(lst))
23 |
24 |
25 | METHOD-03:
26 |
27 | # Reversing a list using slicing technique
28 | def Reverse(lst):
29 | new_lst = lst[::-1]
30 | return new_lst
31 |
32 | lst = [10, 11, 12, 13, 14, 15]
33 | print(Reverse(lst))
34 |
35 |
36 | #END
37 |
--------------------------------------------------------------------------------
/Python/Program-36/README.md:
--------------------------------------------------------------------------------
1 | THIS IS THE PYTHON BASED CODES WHICH HELPS YOU TO REVERSE A LIST FROM 3 DIFFERENT METHODS
2 |
--------------------------------------------------------------------------------
/Python/Program-48/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/.DS_Store
--------------------------------------------------------------------------------
/Python/Program-48/Find_area _of_triangle.py:
--------------------------------------------------------------------------------
1 | a = float(input('Enter first side: '))
2 | b = float(input('Enter second side: '))
3 | c = float(input('Enter third side: '))
4 |
5 | s = (a + b + c) / 2
6 |
7 | area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
8 | print('The area of the triangle is:', area)
9 |
10 |
--------------------------------------------------------------------------------
/Python/Program-48/README.md:
--------------------------------------------------------------------------------
1 | # Lane_Detection
2 | """
3 | basic images have been added to use as templates for this open CV project, which has a fun interface as well
4 | """
--------------------------------------------------------------------------------
/Python/Program-48/media/averagedLines.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/averagedLines.jpg
--------------------------------------------------------------------------------
/Python/Program-48/media/carDashCam.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/carDashCam.mp4
--------------------------------------------------------------------------------
/Python/Program-48/media/edgeFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/edgeFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/final.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/final.gif
--------------------------------------------------------------------------------
/Python/Program-48/media/gaussianFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/gaussianFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/grayFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/grayFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/houghLinesFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/houghLinesFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/originalFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/originalFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/output.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/output.mp4
--------------------------------------------------------------------------------
/Python/Program-48/media/roiFrame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/roiFrame.png
--------------------------------------------------------------------------------
/Python/Program-48/media/roiMask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/Python/Program-48/media/roiMask.png
--------------------------------------------------------------------------------
/Python/Program34/Program34.py:
--------------------------------------------------------------------------------
1 | # First import the calendar module
2 | import calendar
3 | # ask of month and year
4 | yy = int(input("Enter year: "))
5 | mm = int(input("Enter month: "))
6 | # display the calendar
7 | print(calendar.month(yy,mm))
--------------------------------------------------------------------------------
/Python/Program34/Readme.md:
--------------------------------------------------------------------------------
1 | Program to display calender
--------------------------------------------------------------------------------
/Python/Program43/Program43.py:
--------------------------------------------------------------------------------
1 | terms = 10
2 |
3 | # Uncomment code below to take input from the user
4 | # terms = int(input("How many terms? "))
5 |
6 | # use anonymous function
7 | result = list(map(lambda x: 2 ** x, range(terms)))
8 |
9 | print("The total terms are:",terms)
10 | for i in range(terms):
11 | print("2 raised to power",i,"is",result[i])
--------------------------------------------------------------------------------
/Python/Program43/Readme.md:
--------------------------------------------------------------------------------
1 | # Display the powers of 2 using anonymous function
--------------------------------------------------------------------------------
/Python/Program44/Program44.py:
--------------------------------------------------------------------------------
1 | dec = 344
2 |
3 | print("The decimal value of", dec, "is:")
4 | print(bin(dec), "in binary.")
5 | print(oct(dec), "in octal.")
6 | print(hex(dec), "in hexadecimal.")
--------------------------------------------------------------------------------
/Python/Program44/Readme.md:
--------------------------------------------------------------------------------
1 | # Python program to convert decimal into other number systems
--------------------------------------------------------------------------------
/Python/Program45/Program45.py:
--------------------------------------------------------------------------------
1 | def recur_fibo(n):
2 | if n <= 1:
3 | return n
4 | else:
5 | return(recur_fibo(n-1) + recur_fibo(n-2))
6 |
7 | nterms = 10
8 |
9 | # check if the number of terms is valid
10 | if nterms <= 0:
11 | print("Plese enter a positive integer")
12 | else:
13 | print("Fibonacci sequence:")
14 | for i in range(nterms):
15 | print(recur_fibo(i))
--------------------------------------------------------------------------------
/Python/Program45/Readme.md:
--------------------------------------------------------------------------------
1 | # Python program to display the Fibonacci sequence
--------------------------------------------------------------------------------
/Python/Program46/Program46.py:
--------------------------------------------------------------------------------
1 | # Program make a simple calculator
2 |
3 | # This function adds two numbers
4 | def add(x, y):
5 | return x + y
6 |
7 | # This function subtracts two numbers
8 | def subtract(x, y):
9 | return x - y
10 |
11 | # This function multiplies two numbers
12 | def multiply(x, y):
13 | return x * y
14 |
15 | # This function divides two numbers
16 | def divide(x, y):
17 | return x / y
18 |
19 |
20 | print("Select operation.")
21 | print("1.Add")
22 | print("2.Subtract")
23 | print("3.Multiply")
24 | print("4.Divide")
25 |
26 | while True:
27 | # take input from the user
28 | choice = input("Enter choice(1/2/3/4): ")
29 |
30 | # check if choice is one of the four options
31 | if choice in ('1', '2', '3', '4'):
32 | num1 = float(input("Enter first number: "))
33 | num2 = float(input("Enter second number: "))
34 |
35 | if choice == '1':
36 | print(num1, "+", num2, "=", add(num1, num2))
37 |
38 | elif choice == '2':
39 | print(num1, "-", num2, "=", subtract(num1, num2))
40 |
41 | elif choice == '3':
42 | print(num1, "*", num2, "=", multiply(num1, num2))
43 |
44 | elif choice == '4':
45 | print(num1, "/", num2, "=", divide(num1, num2))
46 |
47 | # check if user wants another calculation
48 | # break the while loop if answer is no
49 | next_calculation = input("Let's do next calculation? (yes/no): ")
50 | if next_calculation == "no":
51 | break
52 |
53 | else:
54 | print("Invalid Input")
--------------------------------------------------------------------------------
/Python/Program46/Readme.md:
--------------------------------------------------------------------------------
1 | # Simple Calculator by Using Functions
--------------------------------------------------------------------------------
/Python/Program47/Program47.py:
--------------------------------------------------------------------------------
1 | # Python program to shuffle a deck of card
2 |
3 | # importing modules
4 | import itertools, random
5 |
6 | # make a deck of cards
7 | deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))
8 |
9 | # shuffle the cards
10 | random.shuffle(deck)
11 |
12 | # draw five cards
13 | print("You got:")
14 | for i in range(5):
15 | print(deck[i][0], "of", deck[i][1])
16 |
--------------------------------------------------------------------------------
/Python/Program47/Readme.md:
--------------------------------------------------------------------------------
1 | # Python program to shuffle a deck of card
2 |
--------------------------------------------------------------------------------
/Python/program-1/program.py:
--------------------------------------------------------------------------------
1 | print("Hello, World!")
--------------------------------------------------------------------------------
/Python/program-10/program.py:
--------------------------------------------------------------------------------
1 | # Python program to shuffle a deck of card
2 |
3 | import itertools, random
4 |
5 | deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))
6 |
7 | random.shuffle(deck)
8 |
9 | print("woohh here you got:")
10 | for i in range(5):
11 | print(deck[i][0], "of", deck[i][1])
12 |
--------------------------------------------------------------------------------
/Python/program-11/program.py:
--------------------------------------------------------------------------------
1 | #fibonacci series
2 | nterms = int(input("How many terms? "))
3 |
4 | # first two terms
5 | n1, n2 = 0, 1
6 | count = 0
7 |
8 | if nterms <= 0:
9 | print("Please enter a positive integer")
10 | elif nterms == 1:
11 | print("Fibonacci sequence upto",nterms,":")
12 | print(n1)
13 | else:
14 | print("Fibonacci sequence:")
15 | while count < nterms:
16 | print(n1)
17 | nth = n1 + n2
18 | # update values
19 | n1 = n2
20 | n2 = nth
21 | count += 1
--------------------------------------------------------------------------------
/Python/program-12/program.py:
--------------------------------------------------------------------------------
1 | # Program to check if a number is prime or not
2 |
3 | num = 407
4 |
5 | # To take input from the user
6 | #num = int(input("Enter a number: "))
7 |
8 | # prime numbers are greater than 1
9 | if num > 1:
10 | # check for factors
11 | for i in range(2,num):
12 | if (num % i) == 0:
13 | print(num,"is not a prime number")
14 | print(i,"times",num//i,"is",num)
15 | break
16 | else:
17 | print(num,"is a prime number")
18 |
19 | # if input number is less than
20 | # or equal to 1, it is not prime
21 | else:
22 | print(num,"is not a prime number")
--------------------------------------------------------------------------------
/Python/program-13/program.py:
--------------------------------------------------------------------------------
1 | # Returns index of x in arr if present, else -1
2 | def binary_search(arr, low, high, x):
3 |
4 | # Check base case
5 | if high >= low:
6 |
7 | mid = (high + low) // 2
8 |
9 | # If element is present at the middle itself
10 | if arr[mid] == x:
11 | return mid
12 |
13 | # If element is smaller than mid, then it can only
14 | # be present in left subarray
15 | elif arr[mid] > x:
16 | return binary_search(arr, low, mid - 1, x)
17 |
18 | # Else the element can only be present in right subarray
19 | else:
20 | return binary_search(arr, mid + 1, high, x)
21 |
22 | else:
23 | # Element is not present in the array
24 | return -1
25 |
26 | # Test array
27 | arr = [ 2, 3, 4, 10, 40 ]
28 | x = 10
29 |
30 | # Function call
31 | result = binary_search(arr, 0, len(arr)-1, x)
32 |
33 | if result != -1:
34 | print("Element is present at index", str(result))
35 | else:
36 | print("Element is not present in array")
--------------------------------------------------------------------------------
/Python/program-13/readme.md:
--------------------------------------------------------------------------------
1 | python program for binary search
--------------------------------------------------------------------------------
/Python/program-14/program.py:
--------------------------------------------------------------------------------
1 | # Python3 program to find simple interest
2 | # for given principal amount, time and
3 | # rate of interest.
4 |
5 | def simple_interest(p,t,r):
6 | print('The principal is', p)
7 | print('The time period is', t)
8 | print('The rate of interest is',r)
9 |
10 | si = (p * t * r)/100
11 |
12 | print('The Simple Interest is', si)
13 | return si
14 |
15 | # Driver code
16 | simple_interest(8, 6, 8)
--------------------------------------------------------------------------------
/Python/program-15/program.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | start = datetime.datetime.now()
3 | arr = [5, 8, 1, 3, 3, 0, 7, 4,5,8, 9, 10, 84, 34, 22]
4 | arr_size = len(arr)
5 | new_arr = [None]*(arr_size)
6 | n = 0
7 |
8 | for i in range(arr_size):
9 | n=0
10 | for j in range(arr_size):
11 | if arr[i] > arr[j]:
12 | n+=1
13 | while new_arr[n] == arr[i]:
14 | n+=1
15 | new_arr[n] = arr[i]
16 |
17 | arr = new_arr
18 |
19 | for i in range(arr_size):
20 | print ("%d" %arr[i]),
21 |
22 | finish = datetime.datetime.now()
23 | print (finish-start)
24 |
--------------------------------------------------------------------------------
/Python/program-16/program.py:
--------------------------------------------------------------------------------
1 | for i in range(5):
2 | for j in range(i):
3 | print('*', end=' ')
4 | print()
--------------------------------------------------------------------------------
/Python/program-17/program.py:
--------------------------------------------------------------------------------
1 | #Python Program to Convert Decimal to Binary
2 |
3 | def decimalToBinary(num):
4 | """This function converts decimal number
5 | to binary and prints it"""
6 | if num > 1:
7 | decimalToBinary(num // 2)
8 | print(num % 2, end='')
9 |
10 |
11 | # decimal number
12 | number = int(input("Enter any decimal number: "))
13 |
14 | decimalToBinary(number)
15 |
--------------------------------------------------------------------------------
/Python/program-18/program.py:
--------------------------------------------------------------------------------
1 |
2 | year = int( input('Enter Year: '))
3 |
4 | if (year%4) and (year%100) and (year%400) == 0:
5 | print('Leap year')
6 | else:
7 | print('Not leap year')
8 |
--------------------------------------------------------------------------------
/Python/program-19/program.py:
--------------------------------------------------------------------------------
1 | a = int(input())
2 | count = 0
3 | list_1 = [i for i in range(1, 51)]
4 |
5 | for i in list_1:
6 | if i != a:
7 | if i%a == 0:
8 | count+=1
9 |
10 | print(count,end='')
--------------------------------------------------------------------------------
/Python/program-2/program.py:
--------------------------------------------------------------------------------
1 | fact=int(input("input any number"))
2 | # input any number
3 | factorial = 1
4 | #predefined factorial of 0
5 | if fact < 0:
6 | print("factorial is not possible")
7 | elif fact == 0:
8 | print("factorial of "+str(fact) +" is "+str(factorial))
9 | else:
10 | fact1=fact
11 | while(fact>2):
12 | fact-=1
13 | fact1=fact1*(fact)
14 | print("factorial is "+ str(fact1))
--------------------------------------------------------------------------------
/Python/program-20/program.py:
--------------------------------------------------------------------------------
1 | a,b = input().split()
2 |
3 | a = int(a)
4 | b = int(b)
5 |
6 | list_1 = list(x for x in range(a+1,b+1))
7 |
8 | for i in list_1[a:b]:
9 | print(i)
--------------------------------------------------------------------------------
/Python/program-32/Program32.py:
--------------------------------------------------------------------------------
1 | # defining a function to calculate LCM
2 | def calculate_lcm(x, y):
3 | # selecting the greater number
4 | if x > y:
5 | greater = x
6 | else:
7 | greater = y
8 | while(True):
9 | if((greater % x == 0) and (greater % y == 0)):
10 | lcm = greater
11 | break
12 | greater += 1
13 | return lcm
14 |
15 | # taking input from users
16 | num1 = int(input("Enter first number: "))
17 | num2 = int(input("Enter second number: "))
18 | # printing the result for the users
19 | print("The L.C.M. of", num1,"and", num2,"is", calculate_lcm(num1, num2))
--------------------------------------------------------------------------------
/Python/program-32/Readme (2).md:
--------------------------------------------------------------------------------
1 | Program to Calculate LCM of two number
--------------------------------------------------------------------------------
/Python/program-32/readme.md:
--------------------------------------------------------------------------------
1 | Returns the human-readable format of the given number of seconds.
--------------------------------------------------------------------------------
/Python/program-4/program.py:
--------------------------------------------------------------------------------
1 | # Store input numbers
2 | num1 = input('Enter first number: ')
3 | num2 = input('Enter second number: ')
4 |
5 | # Add two numbers
6 | sum = float(num1) + float(num2)
7 |
8 | # Display the sum
9 | print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
10 |
--------------------------------------------------------------------------------
/Python/program-41/README.md:
--------------------------------------------------------------------------------
1 | Program 41
2 |
3 | Tic-Tac-Toe Game in python.
4 |
--------------------------------------------------------------------------------
/Python/program-5/README.md:
--------------------------------------------------------------------------------
1 | Program 5
2 |
3 | This program gives the following pattern:
4 |
5 | 1
6 | 1 2 1 2
7 | 1 2 3 1 2 3
8 | 1 2 3 4 1 2 3 4
9 | 1 2 3 4 5 1 2 3 4 5
10 |
11 |
--------------------------------------------------------------------------------
/Python/program-5/pragram.py:
--------------------------------------------------------------------------------
1 | for i in range(1,6):
2 | for j in range(1,6-i):
3 | print(" ",end=" ")
4 | for k in range(1,i+1):
5 | print(k,end=" ")
6 | if i>1:
7 | for l in range(1,i+1):
8 | print(l,end=" ")
9 | print()
10 |
--------------------------------------------------------------------------------
/Python/program-5/program.py:
--------------------------------------------------------------------------------
1 | rows = int(input("Enter Same Number Rows & Columns Square Pattern Rows = "))
2 |
3 | print("===Printing Same Number in Rows and Columns of a Square Pattern===")
4 |
5 | for i in range(1, rows + 1):
6 | for j in range(i, rows + 1):
7 | print(j, end = ' ')
8 | for k in range(1, i):
9 | print(k, end = ' ')
10 | print()
--------------------------------------------------------------------------------
/Python/program-6/README.md:
--------------------------------------------------------------------------------
1 | Program 6
2 |
3 | The code gives the following pattern :
4 |
5 | 1
6 | 2 2
7 | 3 3 3
8 | 4 4 4 4
9 | 5 5 5 5 5
10 |
11 |
--------------------------------------------------------------------------------
/Python/program-6/program.py:
--------------------------------------------------------------------------------
1 | for i in range(1,6):
2 | for j in range(1,i+1):
3 | print(i,end=' ')
4 | print()
5 |
--------------------------------------------------------------------------------
/Python/program-7/program.py:
--------------------------------------------------------------------------------
1 | #pattern
2 | for i in range(1,6):
3 | for j in range (1,6-i):
4 | print(" ",end=" ")
5 | for k in range(1,i+1):
6 | print(k,end=" ")
7 | print()
8 |
--------------------------------------------------------------------------------
/Python/program-7/readme.md:
--------------------------------------------------------------------------------
1 | Program to print the following pattern
2 | 1
3 | 1 2
4 | 1 2 3
5 | 1 2 3 4
6 | 1 2 3 4 5
--------------------------------------------------------------------------------
/Python/program-8/program.py:
--------------------------------------------------------------------------------
1 | c=0
2 | for i in range(0,4):
3 | for j in range(i+1):
4 | print(c,end=" ")
5 | c=c+1
6 | print()
--------------------------------------------------------------------------------
/Python/program-8/readme.md:
--------------------------------------------------------------------------------
1 | program to print the given pattern
2 | 0
3 | 1 2
4 | 3 4 5
5 | 6 7 8 9
--------------------------------------------------------------------------------
/Python/program-9/program.py:
--------------------------------------------------------------------------------
1 | #Python Program to Find Armstrong Number in an Interval
2 |
3 |
4 | lower = 100
5 | upper = 2000
6 |
7 | for num in range(lower, upper + 1):
8 |
9 | # order of number
10 | order = len(str(num))
11 |
12 | # initialize sum
13 | sum = 0
14 |
15 | temp = num
16 | while temp > 0:
17 | digit = temp % 10
18 | sum += digit ** order
19 | temp //= 10
20 |
21 | if num == sum:
22 | print(num)
23 |
--------------------------------------------------------------------------------
/flask app/app.py:
--------------------------------------------------------------------------------
1 | from flask import Flask,session,flash,render_template,redirect,session,url_for,request
2 |
3 | app = Flask(__name__)
4 | # UPLOAD_FOLDER = r'.\uploads'
5 | # DOWNLOAD_FOLDER = r'.\downloads'
6 | # TEMP_FOLDER = './temps'
7 | app.secret_key = 'awedfrtyyyrwwe'
8 | # app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
9 | # app.config['DOWNLOAD_FOLDER'] = DOWNLOAD_FOLDER
10 | # app.config['TEMP_FOLDER'] = TEMP_FOLDER
11 |
12 | @app.route('/')
13 | def main():
14 | return render_template('index.html')
15 |
16 |
17 | if __name__ == "__main__":
18 | app.run()
--------------------------------------------------------------------------------
/flask app/static/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/flask app/static/1.jpg
--------------------------------------------------------------------------------
/flask app/static/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/flask app/static/1.png
--------------------------------------------------------------------------------
/flask app/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Basic Programs
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Basic Programs
14 | Basic programs in C and Python
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/gif/giphy.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/gif/giphy.gif
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Basic Programs
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Basic Programs
13 | Basic programs in C and Python
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/kotlin/Program1/README.md:
--------------------------------------------------------------------------------
1 | Q1. Write a program to print half pyramid using ' * '
2 |
3 | Ask no. of rows from the user in variable "rows"
4 |
--------------------------------------------------------------------------------
/kotlin/Program1/pattern.kt:
--------------------------------------------------------------------------------
1 |
2 | fun main(args: Array) {
3 | print("Enter no. of rows : ")
4 | val rows = readLine()
5 | if (rows != null) {
6 | for (i in 1..rows.toInt()) {
7 | for (j in 1..i) {
8 | print("* ")
9 | }
10 | println()
11 | }
12 | }
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/kotlin/Program2/README.md:
--------------------------------------------------------------------------------
1 | Q2. Write a program to plus and minus with sample of extension function from kotlin
2 |
--------------------------------------------------------------------------------
/kotlin/Program2/extension.kt:
--------------------------------------------------------------------------------
1 | fun main(args: Array) {
2 | println("Basic Extension Function")
3 | val plus = 2.plusNumber(2)
4 | val minus = 2.minusNumber(2)
5 | println("2 + 2 : $plus")
6 | println("2 - 2 : $minus")
7 | }
8 |
9 | fun Int.plusNumber(number: Int): Int {
10 | return this + number
11 | }
12 |
13 | fun Int.minusNumber(number: Int): Int {
14 | return this - number
15 | }
--------------------------------------------------------------------------------
/kotlin/Program3/README.md:
--------------------------------------------------------------------------------
1 | Write a program to filter number from list in kotlin
2 |
--------------------------------------------------------------------------------
/kotlin/Program3/filterList.kt:
--------------------------------------------------------------------------------
1 | fun main(args: Array) {
2 | println("Basic Filter List Function")
3 | val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
4 | val odd = numbers.filter { it % 2 != 0 }
5 | val even = numbers.filter { it % 2 == 0 }
6 | val moreThan10 = numbers.filter { it > 10 }
7 |
8 | println("odd: $odd")
9 | println("even: $even")
10 | println("moreThan10: $moreThan10")
11 |
12 | val listDay= listOf("Senin","Selasa","Senin","Kamis","Jumat","Sabtu","Minggu")
13 | val containsS = listDay.filter { it.contains("s") }
14 | val equal = listDay.filter { it == "Selasa" }
15 | val length = listDay.filter { it.length > 5 }
16 | println("contains S: $containsS")
17 | println("equal: $equal")
18 | println("length: $length")
19 | }
--------------------------------------------------------------------------------
/kotlin/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Kotlin
4 | | Program No.| Question |
5 | | ------- | ------ |
6 | | [Program-1](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/kotlin/Program1/pattern.kt) | Write a program to print half pyramid using ' * '
7 | | [Program-2](https://github.com/swaaz/basicprograms/blob/master/kotlin/Program2/extension.kt) | Q2. Write a program to plus and minus with sample of extension function from kotlin
8 | | [Program-3](https://github.com/swaaz/basicprograms/blob/master/kotlin/Program3/filterList.kt) | Write a program to filter number from list in kotlin
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pattern.py:
--------------------------------------------------------------------------------
1 | from turtle import*
2 | speed(10)
3 | color('cyan')
4 | bgcolor('black')
5 | b = 200
6 | while b>0:
7 | left(b)
8 | forward(b*3)
9 | b=b-1
10 |
--------------------------------------------------------------------------------
/program.py:
--------------------------------------------------------------------------------
1 | celsius_1 = float(input("Temperature value in degree Celsius: " ))
2 |
3 | # For Converting the temperature to degree Fahrenheit by using the above
4 | # given formula
5 | Fahrenheit_1 = (celsius_1 * 1.8) + 32
6 |
7 | # print the result
8 | print('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
9 | %(celsius_1, Fahrenheit_1))
10 |
11 | print("----OR----")
12 | celsius_2 = float (input("Temperature value in degree Celsius: " ))
13 | Fahrenheit_2 = (celsius_2 * 9/5) + 32
14 |
15 | # print the result
16 | print ('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
17 | %(celsius_2, Fahrenheit_2))
18 |
--------------------------------------------------------------------------------
/src/css/index.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/src/css/index.css
--------------------------------------------------------------------------------
/src/images/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/src/images/1.jpg
--------------------------------------------------------------------------------
/src/js/index.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swaaz/basicprograms/1da80d646cd23a77c109f0b7fa2cda598c726ba2/src/js/index.js
--------------------------------------------------------------------------------