Skip to content

Instantly share code, notes, and snippets.

View MoorthySuresh's full-sized avatar

MoorthySuresh

View GitHub Profile
import psutil
from matplotlib import pyplot as plt
import datetime
import time
from urllib.request import urlopen
import sys
from multiprocessing import Process
from threading import Thread
import signal
import csv
@MoorthySuresh
MoorthySuresh / Creditcard_Validator_Regex.py
Created January 24, 2021 14:41
Credit card validtion using Regex
import re
#Luhn algorithm
#Credit_Card=input("Enter your credit card number: ")
Credit_Card="370789709084107"
rCredit_Card=Credit_Card[::-1]#reversing the string
sCredit_Card=rCredit_Card.strip()#removing spaces before and after a string, if any
total=0
for index, value in enumerate (sCredit_Card):
if index%2!=0: #extracting even position of digits from left to right.
@MoorthySuresh
MoorthySuresh / Creditcard_Checkdigit.py
Created January 21, 2021 06:28
Cross checking the check-digit of a valid credit card
#Luhn algorithm
#Credit_Card=input("Enter your credit card number: ")
Credit_Card="379762088600299"
rCredit_Card=Credit_Card[::-1]#reversing the string
print(rCredit_Card)
sCredit_Card=rCredit_Card.strip()#removing spaces before and after a string, if any
r1Credit_Card=sCredit_Card[1:]
print(r1Credit_Card)#CheckDigit removed
total=0
for index, value in enumerate (r1Credit_Card):
#Luhn algorithm
#Credit_Card=input("Enter your credit card number: ")
Credit_Card="38520000023237"
rCredit_Card=Credit_Card[::-1]#reversing the string
sCredit_Card=rCredit_Card.strip()#removing spaces before and after a string, if any
#print(cn)
total=0
for index, value in enumerate (sCredit_Card):
if index%2!=0: #extracting even position of digits from left to right.
x=int(value)*2 #doubling the even position of digits from left to right
def fact(n):
if n==0:
return 1
return n*fact(n-1)
result=fact(5)
print(result)
#gussing three number in a list #guessing game
import random
l = []
for i in range(0,3):
n = random.randint(1,9)
l.append(n)
n=["X","X","X"]
o=["C", "C","C"]
#final=[]
y=0
l=[1,8,2,6,4,54,2]
n=len(l)-1
for i in range(0,n):
for j in range(0,n):
if l[j]>l[j+1]:
l[j],l[j+1]=l[j+1],l[j]
print(l)
l= [2,5,8,1,4]
j=0
while j<len(l):
i=0
while i<len(l)-1:
if l[i]>l[i+1]:
l[i],l[i+1]=l[i+1],l[i]
i+=1
j+=1
print(l)
name="suresh"
d={}
for x in name:
d[x]=d.get(x,0)+1
print(d)
total=0
i=0
while i<=100:
total=total+i
i+=1
print(total)