-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
646 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
a = 10 | ||
b = int(input("Enter any number ")) | ||
try: | ||
c = a/b | ||
except: | ||
print('Cannot divide NUMBER by STRING') | ||
else: | ||
print('Result :', c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# program to find out decimal number of any given binary number | ||
# made by : rakesh kumar | ||
n = int(input('Enter any number :')) | ||
sum = 0 | ||
i = 0 | ||
while n != 0: | ||
rem = n % 10 | ||
sum = sum+rem*2**i | ||
n = n//10 | ||
i = i+1 | ||
|
||
print('Decimal Equivalent :', sum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# program to find out binary equivalent of any decimal number | ||
# made by : rakesh kumar | ||
|
||
n = int(input('Enter any number :')) | ||
l = '' | ||
while(n != 0): | ||
l = str(n % 2) + l | ||
n = n//2 | ||
|
||
print(l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,2 @@ | ||
# program to find out EMI using formula | ||
# EMI = (p*r(1+r)**t)/((1+r)**t-1) | ||
# made by : rakesh kumar | ||
|
||
from math import pow | ||
|
||
|
||
def emi_calculate(p, r, t): | ||
r = r/(12*100) # rate for one month | ||
t = t*12 # one month time | ||
emi = (p*r*pow(1+r, t))/(pow(1+r, t)-1) | ||
return emi | ||
|
||
|
||
if __name__ == "__main__": | ||
p = int(input('Enter pricipal amount :')) | ||
r = int(input('Enter rate of interest :')) | ||
t = int(input('Enter time in years :')) | ||
emi = emi_calculate(p, r, t) | ||
|
||
print('Monthly Installment :%.2f' % emi) | ||
i = i+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
board = [ | ||
[7, 8, 0, 4, 0, 0, 1, 2, 0], | ||
[6, 0, 0, 0, 7, 5, 0, 0, 9], | ||
[0, 0, 0, 6, 0, 1, 0, 7, 8], | ||
[0, 0, 7, 0, 4, 0, 2, 6, 0], | ||
[0, 0, 1, 0, 5, 0, 9, 3, 0], | ||
[9, 0, 4, 0, 6, 0, 0, 0, 5], | ||
[0, 7, 0, 3, 0, 0, 0, 1, 2], | ||
[1, 2, 0, 0, 0, 7, 4, 0, 0], | ||
[0, 4, 9, 2, 0, 6, 0, 0, 7] | ||
] | ||
|
||
|
||
def solve(bo): | ||
find = find_empty(bo) | ||
if not find: | ||
return True | ||
else: | ||
row, col = find | ||
|
||
for i in range(1, 10): | ||
if valid(bo, i, (row, col)): | ||
bo[row][col] = i | ||
|
||
if solve(bo): | ||
return True | ||
|
||
bo[row][col] = 0 | ||
|
||
return False | ||
|
||
|
||
def valid(bo, num, pos): | ||
# Check row | ||
for i in range(len(bo[0])): | ||
if bo[pos[0]][i] == num and pos[1] != i: | ||
return False | ||
|
||
# Check column | ||
for i in range(len(bo)): | ||
if bo[i][pos[1]] == num and pos[0] != i: | ||
return False | ||
|
||
# Check box | ||
box_x = pos[1] // 3 | ||
box_y = pos[0] // 3 | ||
|
||
for i in range(box_y*3, box_y*3 + 3): | ||
for j in range(box_x * 3, box_x*3 + 3): | ||
if bo[i][j] == num and (i, j) != pos: | ||
return False | ||
|
||
return True | ||
|
||
|
||
def print_board(bo): | ||
for i in range(len(bo)): | ||
if i % 3 == 0 and i != 0: | ||
print("- - - - - - - - - - - - - ") | ||
|
||
for j in range(len(bo[0])): | ||
if j % 3 == 0 and j != 0: | ||
print(" | ", end="") | ||
|
||
if j == 8: | ||
print(bo[i][j]) | ||
else: | ||
print(str(bo[i][j]) + " ", end="") | ||
|
||
|
||
def find_empty(bo): | ||
for i in range(len(bo)): | ||
for j in range(len(bo[0])): | ||
if bo[i][j] == 0: | ||
return (i, j) # row, col | ||
|
||
return None | ||
|
||
|
||
print_board(board) | ||
solve(board) | ||
print("___________________") | ||
print_board(board) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
#------------------------------------------------------------------------------- | ||
# Name: Program to delete a particular type of files from selected directory | ||
# ------------------------------------------------------------------------------- | ||
# Name: Program to delete a particular type of files from selected directory | ||
# | ||
# Author: rakesh | ||
# | ||
# Created: 05-05-2017 | ||
# Copyright: MIT | ||
#------------------------------------------------------------------------------- | ||
# ------------------------------------------------------------------------------- | ||
import os | ||
import sys #module for terminating | ||
import sys # module for terminating | ||
import glob | ||
import tkinter as tk | ||
from tkinter import filedialog | ||
|
||
|
||
def main(): | ||
root = tk.Tk() | ||
root.withdraw() | ||
directory = filedialog.askdirectory() #source folder | ||
count=0 | ||
for root, SubFolders , files in os.walk(directory): | ||
directory = filedialog.askdirectory() # source folder | ||
count = 0 | ||
for root, SubFolders, files in os.walk(directory): | ||
os.chdir(root) | ||
files = glob.glob('*.exe') | ||
files = glob.glob('*.nef') | ||
# print(files) | ||
for filename in files: | ||
print(filename, 'Deleted') | ||
os.unlink(filename) | ||
count+=1 | ||
count += 1 | ||
print("Total {} files deleted".format(count)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
def addition(a, b=0): | ||
return a+b | ||
|
||
|
||
result = addition(10) | ||
print(result) | ||
result = addition('rakesh', ' You are awesome') | ||
print(result) | ||
result = addition(20, 30.45) | ||
print(result) | ||
result = addition([10, 20, 30], [40, 50, 60]) | ||
print(result) | ||
result = addition((10, 20, 30), (40, 50, 60)) | ||
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
def armstrong(n): | ||
m = n | ||
sum = 0 | ||
while(n != 0): | ||
rem = n % 10 | ||
sum += rem**3 | ||
n = n//10 | ||
return True if sum == m else False | ||
|
||
|
||
if __name__ == "__main__": | ||
n = int(input('Enter any number :')) | ||
print('ArmStrong Number ' if(armstrong(n)) else 'Not a Arm Strong Number ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
def armstrong(n): | ||
m = n | ||
sum = 0 | ||
while(n != 0): | ||
rem = n % 10 | ||
sum += rem**3 | ||
n = n//10 | ||
return True if sum == m else False | ||
|
||
|
||
if __name__ == "__main__": | ||
n1 = int(input('Enter first value :')) | ||
n2 = int(input('Enter last value :')) | ||
for x in range(n1, n2+1): | ||
if(armstrong(x)): | ||
print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import math as m | ||
|
||
|
||
def check_prime(n): | ||
flag = True | ||
for x in range(2, n//2): | ||
if n % x == 0: | ||
flag = False | ||
|
||
return flag | ||
|
||
if __name__ == "__main__": | ||
n = int(input('Enter any integer number : ')) | ||
result = check2_prime(n) | ||
print("Prime Number " if (result) else '"Not prime Number') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def common(l1, l2): | ||
c = list() | ||
for x in l1: | ||
if x in l2: | ||
c.append(x) | ||
return c | ||
|
||
|
||
l1 = [1, 2, 3, 4, 6, 8, 9] | ||
l2 = [2, 4, 6, 7, 9, 10] | ||
|
||
print(common(l1, l2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def display(number, msg1="School", msg2="Place"): | ||
print('-----Times :', number, end=" ") | ||
print('-----Message 1 :', msg1*2) | ||
print('-----Message 2 :', msg2) | ||
print('----------------------') | ||
|
||
|
||
display(2, 'DAV', 'Ghaziabad') | ||
display(5) | ||
display("SpringDales") | ||
display(msg2="Modern", number=3) | ||
display(msg2="Modern", msg1=24, number=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from math import sqrt | ||
|
||
|
||
def prime_number(n): | ||
flag = True | ||
for x in range(2, int(sqrt(n))+1): | ||
if n % x == 0: | ||
flag = False | ||
return flag | ||
|
||
|
||
if __name__ == "__main__": | ||
if(prime_number(12)): | ||
print('Prime Number') | ||
else: | ||
print('Not a prime Number') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# program to print the prime numbers between a range of numbers. | ||
# made by : rakesh kumar | ||
|
||
|
||
def check_prime(n): | ||
flag = True | ||
for x in range(2, n//2): | ||
if n % x == 0: | ||
flag = False | ||
|
||
return flag | ||
|
||
|
||
if __name__ == "__main__": | ||
n1 = int(input('Enter the starting number : ')) | ||
n2 = int(input('Enter the Ending number number : ')) | ||
|
||
print('Prime Number between :') | ||
for x in range(n1, n2+1): | ||
result = check_prime(x) | ||
if result: | ||
print(x, end=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
# program to find out sum of element of a list using recursion | ||
# made by : rakesh kumar | ||
|
||
|
||
def sum_element(l): | ||
if(len(l) == 1): | ||
return l[0] | ||
else: | ||
value = l.pop() | ||
return value+sum_element(l) | ||
def check_prime(n): | ||
flag = True | ||
for x in range(2, n//2): | ||
if n % x == 0: | ||
flag = False | ||
|
||
return flag | ||
|
||
if __name__ == "__main__": | ||
|
||
list1 = [1, 2, 34, 5, 6] | ||
result = sum_element(list1) | ||
print('sum of element :', result) | ||
n = int(input('Enter any integer number : ')) | ||
result = check_prime(n) | ||
print("Prime Number " if (result) else '"Not prime Number') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import json | ||
import requests | ||
source = requests.get('https://jsonplaceholder.typicode.com/todos/1') | ||
print(source.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
# program to print scatter graph on the screen | ||
# program to print bar graph on the screen | ||
# made by : rakesh kumar | ||
|
||
import matplotlib.pyplot as plt | ||
x = ['Delhi','Banglore','Chennai','Pune'] | ||
y = [250,300,260,400] | ||
plt.bar(x,y) | ||
plt.show() | ||
x = ['Delhi', 'Banglore', 'Chennai', 'Pune'] | ||
y = [250, 300, 260, 400] | ||
plt.xlabel('City') | ||
plt.ylabel('Sales in Million') | ||
plt.title('Sales Recorded in Major Cities') | ||
plt.bar(x, y) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# program to print scatter graph on the screen | ||
# made by : rakesh kumar | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
x = ['Delhi','Banglore','Chennai','Pune','Ghaziabad','Udupi'] | ||
y = [250,300,260,400,599,320] | ||
plt.pie(y,labels=x,autopct='%1.2f',startangle=90,explode=(0,0.1,0,0,0.2,0)) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.