From 4cd32d3267f2144d07606b31f1686529769f0364 Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:36:23 -0800 Subject: [PATCH 01/10] WAP To Reverse a List In Python --- Python/Program-36/Program-36.py | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Python/Program-36/Program-36.py diff --git a/Python/Program-36/Program-36.py b/Python/Program-36/Program-36.py new file mode 100644 index 00000000..4b2d10dd --- /dev/null +++ b/Python/Program-36/Program-36.py @@ -0,0 +1,36 @@ +#WAP TO REVERSING A LIST IN PYTHON + +#METHOD-01: + +# Reversing a list using reversed() +def Reverse(lst): + return [ele for ele in reversed(lst)] + +# Driver Code +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +#METHOD-02: + +# Reversing a list using reverse() +def Reverse(lst): + lst.reverse() + return lst + +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +METHOD-03: + +# Reversing a list using slicing technique +def Reverse(lst): + new_lst = lst[::-1] + return new_lst + +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +#END From 9aee6e67c3f0dbf1c2d227254a61d0b52ddc481a Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:38:38 -0800 Subject: [PATCH 02/10] Create README.md --- Python/Program-36/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Python/Program-36/README.md diff --git a/Python/Program-36/README.md b/Python/Program-36/README.md new file mode 100644 index 00000000..bd3e7e73 --- /dev/null +++ b/Python/Program-36/README.md @@ -0,0 +1 @@ +THIS IS THE PYTHON BASED CODES WHICH HELPS YOU TO REVERSE A LIST FROM 3 DIFFERENT METHODS From f5fa86c90e2ba0b4b6393c4716228b5f9f507ae2 Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:43:33 -0800 Subject: [PATCH 03/10] Update README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index b7e94009..e44831be 100644 --- a/Python/README.md +++ b/Python/README.md @@ -37,7 +37,7 @@ | [Program-33](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program33/Program33.py) | Program to find HCF | [Program-34](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program34/Program34.py) | Program to display calender | [Program-35](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program%2035/Program35.py) | Program to search an element in a Circular Linked List -| Program-36 | - | +| [Program-36](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program-36/Program-36.py) | Program to Reverse a list | Program-37 | - | | Program-38 | - | | Program-39 | - | From b9d8c2b4446c35f9401ace2e1187178654d9b0b5 Mon Sep 17 00:00:00 2001 From: Jovanka Date: Wed, 13 Oct 2021 14:49:12 +0700 Subject: [PATCH 04/10] feat: create program for retrieve data from form html --- Javascript/program-16/index.html | 31 ++++++++++++++++++ Javascript/program-16/index.js | 55 ++++++++++++++++++++++++++++++++ Javascript/program-16/readme.md | 3 ++ 3 files changed, 89 insertions(+) create mode 100644 Javascript/program-16/index.html create mode 100644 Javascript/program-16/index.js create mode 100644 Javascript/program-16/readme.md diff --git a/Javascript/program-16/index.html b/Javascript/program-16/index.html new file mode 100644 index 00000000..a2a06237 --- /dev/null +++ b/Javascript/program-16/index.html @@ -0,0 +1,31 @@ + + + + + + + Get Data + + +
+
+ + +
+
+ + +
+
+ + + +
+ + +
+ + + + + \ No newline at end of file diff --git a/Javascript/program-16/index.js b/Javascript/program-16/index.js new file mode 100644 index 00000000..9b572c40 --- /dev/null +++ b/Javascript/program-16/index.js @@ -0,0 +1,55 @@ +document.addEventListener('DOMContentLoaded', () => { + // get form element + const formElement = document.querySelector('#form'); + + // add event for submit form + formElement.addEventListener('submit', (e) => { + e.preventDefault(); + + // email regex for check email + const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + + // make form data + const formData = new FormData(formElement); + + // get data + const name = formData.get('user_name'); + const email = formData.get('user_email'); + const password = formData.get('user_password'); + + if (!name) { + alert('Name field is empty. Please fill it'); + } else if (!email) { + alert('Email field is empty. Please fill it'); + } else if (!emailRegex.test(email)) { + alert('Email is not valid'); + } else if (!password) { + alert('Password field is empty. Please fill it'); + } else if (password.length < 8) { + alert('Password minimal 8 character'); + } else { + alert('Success'); + alert(`Welcome ${name}`); + + // clear form + formElement.reset(); + } + + }); + + togglePassword(); +}); + +const togglePassword = () => { + // toggle password + const passwordInput = document.querySelector('#user_password'); + const passwordToggle = document.querySelector('#toggle_password'); + + passwordToggle.addEventListener('click', () => { + if (passwordInput.type === 'password') { + passwordInput.type = 'text'; + } else { + passwordInput.type = 'password'; + } + }); +} diff --git a/Javascript/program-16/readme.md b/Javascript/program-16/readme.md new file mode 100644 index 00000000..4d904edb --- /dev/null +++ b/Javascript/program-16/readme.md @@ -0,0 +1,3 @@ +# Program 16 + +Retrieve data from HTML form and validate it From 86d2c621d1b9acbe1300de6743758dd3a9ac96cd Mon Sep 17 00:00:00 2001 From: ARYAN706 Date: Wed, 13 Oct 2021 16:41:47 +0530 Subject: [PATCH 05/10] PROGRAM FOR BINARY SEARCH --- C++/program 29/PROGRAM.CPP | 43 ++++++++++++++++++++++++++++++++++++++ C++/program 29/README.md | 0 2 files changed, 43 insertions(+) create mode 100644 C++/program 29/PROGRAM.CPP create mode 100644 C++/program 29/README.md diff --git a/C++/program 29/PROGRAM.CPP b/C++/program 29/PROGRAM.CPP new file mode 100644 index 00000000..a5145cb9 --- /dev/null +++ b/C++/program 29/PROGRAM.CPP @@ -0,0 +1,43 @@ +// Program to demonstrate BINARY SEARCH +#include +#define SIZE 8 +using namespace std; +int binarySearch(int list[], int size, int item) +{ +int low = 0, mid = 0; +int high = size - 1; +for (low = 0; low <= high; ) +{ +mid = (low + high)/2; +if (item > list[mid]) +{ +low = mid + 1; //Search in Right half +} +else if (item < list[mid]) +{ +high = mid - 1; ////Search in left half +} +else +return mid; +} +return -1; +} +int main() +{ +int item; +int flag = -1; //We assume that if function returns an invalid index (say -1) means item NOT found... +int list[] = {1,2,3,4,5,6,11,18}; +cout<<"Enter item to be searched : "; +cin>>item; +flag = binarySearch(list,SIZE,item); +if (flag == -1) +{ +cout< Date: Sat, 16 Oct 2021 22:51:43 +0530 Subject: [PATCH 06/10] added new pgm --- Python/Program43/Program43.py | 11 +++++++++++ Python/Program44/Program44.py | 6 ++++++ Python/Program45/Program45.py | 15 +++++++++++++++ Python/Program45/Readme.md | 1 + 4 files changed, 33 insertions(+) create mode 100644 Python/Program45/Program45.py create mode 100644 Python/Program45/Readme.md diff --git a/Python/Program43/Program43.py b/Python/Program43/Program43.py index e69de29b..a9ab2d9a 100644 --- a/Python/Program43/Program43.py +++ b/Python/Program43/Program43.py @@ -0,0 +1,11 @@ +terms = 10 + +# Uncomment code below to take input from the user +# terms = int(input("How many terms? ")) + +# use anonymous function +result = list(map(lambda x: 2 ** x, range(terms))) + +print("The total terms are:",terms) +for i in range(terms): + print("2 raised to power",i,"is",result[i]) \ No newline at end of file diff --git a/Python/Program44/Program44.py b/Python/Program44/Program44.py index e69de29b..d4a2443f 100644 --- a/Python/Program44/Program44.py +++ b/Python/Program44/Program44.py @@ -0,0 +1,6 @@ +dec = 344 + +print("The decimal value of", dec, "is:") +print(bin(dec), "in binary.") +print(oct(dec), "in octal.") +print(hex(dec), "in hexadecimal.") \ No newline at end of file diff --git a/Python/Program45/Program45.py b/Python/Program45/Program45.py new file mode 100644 index 00000000..53396b4e --- /dev/null +++ b/Python/Program45/Program45.py @@ -0,0 +1,15 @@ +def recur_fibo(n): + if n <= 1: + return n + else: + return(recur_fibo(n-1) + recur_fibo(n-2)) + +nterms = 10 + +# check if the number of terms is valid +if nterms <= 0: + print("Plese enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(nterms): + print(recur_fibo(i)) \ No newline at end of file diff --git a/Python/Program45/Readme.md b/Python/Program45/Readme.md new file mode 100644 index 00000000..11d0c44d --- /dev/null +++ b/Python/Program45/Readme.md @@ -0,0 +1 @@ +# Python program to display the Fibonacci sequence \ No newline at end of file From 442b75a25e69b6d705aecde6562f72bb7a6fb579 Mon Sep 17 00:00:00 2001 From: Avni Shyam Date: Sat, 16 Oct 2021 23:09:58 +0530 Subject: [PATCH 07/10] added new pgm --- Python/Program46/Program46.py | 54 +++++++++++++++++++++++++++++++++++ Python/Program46/Readme.md | 1 + 2 files changed, 55 insertions(+) create mode 100644 Python/Program46/Program46.py create mode 100644 Python/Program46/Readme.md diff --git a/Python/Program46/Program46.py b/Python/Program46/Program46.py new file mode 100644 index 00000000..47616f41 --- /dev/null +++ b/Python/Program46/Program46.py @@ -0,0 +1,54 @@ +# Program make a simple calculator + +# This function adds two numbers +def add(x, y): + return x + y + +# This function subtracts two numbers +def subtract(x, y): + return x - y + +# This function multiplies two numbers +def multiply(x, y): + return x * y + +# This function divides two numbers +def divide(x, y): + return x / y + + +print("Select operation.") +print("1.Add") +print("2.Subtract") +print("3.Multiply") +print("4.Divide") + +while True: + # take input from the user + choice = input("Enter choice(1/2/3/4): ") + + # check if choice is one of the four options + if choice in ('1', '2', '3', '4'): + num1 = float(input("Enter first number: ")) + num2 = float(input("Enter second number: ")) + + if choice == '1': + print(num1, "+", num2, "=", add(num1, num2)) + + elif choice == '2': + print(num1, "-", num2, "=", subtract(num1, num2)) + + elif choice == '3': + print(num1, "*", num2, "=", multiply(num1, num2)) + + elif choice == '4': + print(num1, "/", num2, "=", divide(num1, num2)) + + # check if user wants another calculation + # break the while loop if answer is no + next_calculation = input("Let's do next calculation? (yes/no): ") + if next_calculation == "no": + break + + else: + print("Invalid Input") \ No newline at end of file diff --git a/Python/Program46/Readme.md b/Python/Program46/Readme.md new file mode 100644 index 00000000..07bda29b --- /dev/null +++ b/Python/Program46/Readme.md @@ -0,0 +1 @@ +# Simple Calculator by Using Functions \ No newline at end of file From 71856c391517698768359cdca4e9ecb570e9e716 Mon Sep 17 00:00:00 2001 From: Avni Shyam Date: Sat, 16 Oct 2021 23:13:24 +0530 Subject: [PATCH 08/10] added new pgm --- Python/Program47/Program47.py | 0 Python/Program47/Readme.md | 1 + 2 files changed, 1 insertion(+) create mode 100644 Python/Program47/Program47.py create mode 100644 Python/Program47/Readme.md diff --git a/Python/Program47/Program47.py b/Python/Program47/Program47.py new file mode 100644 index 00000000..e69de29b diff --git a/Python/Program47/Readme.md b/Python/Program47/Readme.md new file mode 100644 index 00000000..c119f410 --- /dev/null +++ b/Python/Program47/Readme.md @@ -0,0 +1 @@ +# Python program to shuffle a deck of card From d4ccc8df2310a9b1274487292f21fa9b6657c7b8 Mon Sep 17 00:00:00 2001 From: Avni Shyam Date: Sat, 16 Oct 2021 23:17:12 +0530 Subject: [PATCH 09/10] added new pgm --- Python/Program47/Program47.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Python/Program47/Program47.py b/Python/Program47/Program47.py index e69de29b..604983b8 100644 --- a/Python/Program47/Program47.py +++ b/Python/Program47/Program47.py @@ -0,0 +1,15 @@ +# Python program to shuffle a deck of card + +# importing modules +import itertools, random + +# make a deck of cards +deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club'])) + +# shuffle the cards +random.shuffle(deck) + +# draw five cards +print("You got:") +for i in range(5): + print(deck[i][0], "of", deck[i][1]) From 57df8ce4360e32725b46fc90c9930717f9689f6c Mon Sep 17 00:00:00 2001 From: ARYAN SHARMA <88881328+ARYAN706@users.noreply.github.com> Date: Sun, 17 Oct 2021 18:57:48 +0530 Subject: [PATCH 10/10] Update README.md --- C++/program 29/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/C++/program 29/README.md b/C++/program 29/README.md index e69de29b..5a39da89 100644 --- a/C++/program 29/README.md +++ b/C++/program 29/README.md @@ -0,0 +1 @@ +THE PROGRAM IS FOR THE BINARY SEARCH