Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions C++/program 29/PROGRAM.CPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Program to demonstrate BINARY SEARCH
#include <iostream>
#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<<endl<<"Item Not Found !! :( ";
}
else
{
cout<<"item found...";
}
return 0;
}

1 change: 1 addition & 0 deletions C++/program 29/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
THE PROGRAM IS FOR THE BINARY SEARCH
31 changes: 31 additions & 0 deletions Javascript/program-16/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get Data</title>
</head>
<body>
<form id="form">
<div class="input-group">
<label for="user_name">Name</label>
<input type="text" name="user_name" id="user_name">
</div>
<div class="input-group">
<label for="user_email">Email</label>
<input type="email" name="user_email" id="user_email">
</div>
<div class="input-group">
<label for="user_password">Password</label>
<input type="password" name="user_password" id="user_password">
<button type="button" id="toggle_password">toggle password</button>
</div>

<button type="submit">Save</button>
</form>

<!-- link to javascript file -->
<script src="./index.js"></script>
</body>
</html>
55 changes: 55 additions & 0 deletions Javascript/program-16/index.js
Original file line number Diff line number Diff line change
@@ -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';
}
});
}
3 changes: 3 additions & 0 deletions Javascript/program-16/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Program 16

Retrieve data from HTML form and validate it
36 changes: 36 additions & 0 deletions Python/Program-36/Program-36.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Python/Program-36/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
THIS IS THE PYTHON BASED CODES WHICH HELPS YOU TO REVERSE A LIST FROM 3 DIFFERENT METHODS
11 changes: 11 additions & 0 deletions Python/Program43/Program43.py
Original file line number Diff line number Diff line change
@@ -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])
6 changes: 6 additions & 0 deletions Python/Program44/Program44.py
Original file line number Diff line number Diff line change
@@ -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.")
15 changes: 15 additions & 0 deletions Python/Program45/Program45.py
Original file line number Diff line number Diff line change
@@ -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))
1 change: 1 addition & 0 deletions Python/Program45/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Python program to display the Fibonacci sequence
54 changes: 54 additions & 0 deletions Python/Program46/Program46.py
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions Python/Program46/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Simple Calculator by Using Functions
15 changes: 15 additions & 0 deletions Python/Program47/Program47.py
Original file line number Diff line number Diff line change
@@ -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])
1 change: 1 addition & 0 deletions Python/Program47/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Python program to shuffle a deck of card
2 changes: 1 addition & 1 deletion Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | - |
Expand Down