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
''' String compression''' | |
def is_substring(longstr, substr): | |
return longstr.find(substr) | |
def strrotation(s1, s2): | |
if len(s1) == len(s2) != 0: | |
return is_substring(s1 + s1, s2) != -1 | |
return False |
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
################################################################################# | |
# Project to simulate the game of SIM based on user inputs # | |
################################################################################# | |
################################################################################# | |
# Program written by : Thomas Jude Rakesh # | |
# Program submitted date : 05/06/2018 # | |
# Program last modified : 01/07/2018 # | |
################################################################################# | |
from random import randint |
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
Python Introduction: | |
*********************** | |
• Variables, constants | |
variable can start with letter or _ not number or any special character can be included | |
• Operators - add, subtract, multiply, divide, %(to get remainder), **(for power) | |
Comparison operators - ==, <=, >= != | |
• indentation matters | |
• Numeric expressions and operators for solving numeric calculations | |
• Integer, Float, String are types of expressions/variables | |
• Conversion of a numeric value in strings can be converted to int or float |
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
//D1RXO7ET JOB 'TST - SORTRT',NOTIFY=D1RXO7E,CLASS=1,MSGCLA | |
//*---SORT EXTRACT REPORT ******* | |
//STEP001 EXEC PGM=SORT | |
//SORTIN DD DSN=D1RXO7E.TEST.JOB.INPUT1,DISP=SHR | |
//SORTOUT DD DSN=D1RXO7E.TEST.JOB.OUTPUT,DISP=SHR | |
//SYSOUT DD SYSOUT=* | |
//SYSIN DD * | |
SORT FIELDS=COPY | |
INCLUDE COND=(30,8,CH,EQ,C'P#1SPW90',AND, | |
6,2,FS,GE,30,AND, |
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
By using IEBEDIT: | |
We can also use IEBEDIT to achieve the same.By using IEBEDIT ,some steps can be included or excluded from running. | |
Sample job: | |
//STEP0001 EXEC PGM=IEBEDIT | |
//SYSPRINT DD SYSOUT=* | |
//SYSUT1 DD DSN=RACFID.JCLLIB(IEBCHK),DISP=SHR | |
//SYSUT2 DD SYSOUT=* | |
//SYSIN DD * |
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 urllib | |
from BeautifulSoup import * | |
URL = raw_input("Enter the URL:") #Enter main URL | |
link_line = int(raw_input("Enter position:")) - 1 #The position of link relative to first link | |
count = int(raw_input("Enter count:")) #The number of times to be repeated | |
while count >= 0: | |
html = urllib.urlopen(URL).read() | |
soup = BeautifulSoup(html) |
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 | |
input = raw_input('Enter file' ) | |
in_fil = open(input) | |
for line in f: | |
line = line.strip() | |
get_num = re.findall('[0-9]+', line) | |
for num in get_num: | |
sum_num = sum_num + int(num) | |
print sum_num |
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 urllib | |
import json | |
# serviceurl = 'http://maps.googleapis.com/maps/api/geocode/json?' | |
serviceurl = 'http://python-data.dr-chuck.net/geojson?' | |
while True: | |
address = raw_input('Enter location: ') | |
if len(address) < 1 : break |
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 json | |
import urllib | |
url = raw_input('Enter URL:') | |
input = urllib.urlopen(url) | |
data = input.read() | |
info = json.loads(data) | |
print info | |
sum_cnt = 0 | |
print info[0]['comments'] |
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
# Use the file name mbox-short.txt as the file name | |
fname = raw_input("Enter file name: ") | |
fh = open(fname) | |
fr = fh.read() | |
fs = fr.strip() | |
sum_conf = 0 | |
count = 0 | |
for line in fh: | |
if not line.startswith("X-DSPAM-Confidence:") : | |
continue |