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
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 |
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
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. |
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
#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): |
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
#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 |
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
def fact(n): | |
if n==0: | |
return 1 | |
return n*fact(n-1) | |
result=fact(5) | |
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
#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 |
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
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) | |
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
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) |
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
name="suresh" | |
d={} | |
for x in name: | |
d[x]=d.get(x,0)+1 | |
print(d) |
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
total=0 | |
i=0 | |
while i<=100: | |
total=total+i | |
i+=1 | |
print(total) |
NewerOlder