Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python Online

#!/usr/bin/python
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print tuple          # Prints complete list
print tuple[0]       # Prints first element of the list
print tuple[1:3]     # Prints elements starting from 2nd till 3rd
print tuple[2:]      # Prints elements starting from 3rd element
print tinytuple * 2  # Prints list two times
print tuple + tinytuple # Prints concatenated list

Execute Python Online

#!/usr/bin/python

list = [ 'abcd', 786 , 2.23 , 'john' , 70.2 ]

tinylist = [123, 'john']

print list         # Prints complete list

print list[0]      # Prints first element of the list

print list[1:3]    # Prints elemements starting from 2nd till 3rd

print list[2:]     # Prints elements starting from 3rd element

print tinylist * 2 # Prints list two times

print list + tinylist # Prints concatenated list

guess

# Hello World program in Python
    
print "Hello World!\n"

Display Chinese Characters

# Hello World program in Python
# coding: utf8
    
print "Hello World!\n"
print '哈哈'

Execute Python Online

# Client program in Python

import socket
host=socket.gethostbyname("tp.lisp-views.org")
port=8888

# Conection to server
s = socket.socket()
s.connect((host, port))
s.send("[email protected]")
with open("myfile"+"index.html",'wb') as f:
 while True :
  data = s.recv(1024)
  print(data)
  if not data:
   break;
  f.write(data);
 f.close();
s.close();
    

Add codes in Athena Query

code_list = ['J9034', 'J9100', 'J9130', 'J9208', 'J9245', 'J9360', 'J9070', 'J9293', 'J1100', 'J9045', 'J9040', 'J9041', 'J9230', 'J9000', 'J9250', 'J9315', 'J9370', 'J9060', 'J7512', 'J9185', 'J0942', 'J9209', 'J0641', 'J1030']

def print_OR_px_query(code_list, code_type):
    for code in code_list:
        print "OR contains({code_type}_list, '{code}')".format(code_type=code_type, code=code)


print_OR_px_query(code_list, 'px')

Filter and Match Jcodes

# import datetime

# # date1 = datetime.date(2019, 2, 3)
# # date2 = datetime.date(2019, 2, 2)

# # print (date1 - date2).total_seconds() /  (60 * 60 * 24)



# # codes_decoded = [u'ChingCode1', u'ChingCode2', u'ChingCode3']
# # print codes_decoded

all_jcodes = ['J9034', 'J9100', 'J9130', 'J9208', 'J9245', 'J9360', 'J9070', 'J9293', 'J1100', 'J9045', 'J9040', 'J9041', 'J9230', 'J9000', 'J9250', 'J9315', 'J9370', 'J9060', 'J7512', 'J9185', 'J0942', 'J9209', 'J0641', 'J1030']

jcodes = '[J9042, J7050, 96413, J8540, 96417, J7512, Q0162, J9070]'



def convert_to_list_of_strings(input_str):
    formatted_str = input_str.replace('[', '')
    formatted_str = formatted_str.replace(']', '')
    
    codes = formatted_str.split(',')
    
    return [str(code).strip() for code in codes]
    


def get_jcodes(code_list):
    return [code for code in code_list if code.startswith('J')]


def find_match(list1, list2):
    set1 = set(list1)
    set2 = set(list2)
    return list(set1.intersection(set2))

code_list = convert_to_list_of_strings(jcodes)

print 'jcodes from claims:', get_jcodes(code_list)
print 'matching codes:', find_match(all_jcodes, code_list)

# jcode_list = ['J9034', 'J9100', 'J9130', 'J9208', 'J9245', 'J9360', 'J9070', 'J9293', 'J1100', 'J9045', 'J9040', 'J9041', 'J9230', 'J9000', 'J9250', 'J9315', 'J9370', 'J9060', 'J7512', 'J9185', 'J0942', 'J9209', 'J0641', 'J1030']

# def print_OR_px_query(jcode_list):
#     for jcode in jcode_list:
#         print "OR contains(px_list, '{0}')".format(jcode)




# print_OR_px_query(jcode_list)

# expected_npis = sorted(['1750546610', '1437398591', '1164566550', '1558362137', '1588648786', '1275714669', '1639225121', '1174560015', '1811968852', '1467407213', '1407912116', '1396951299', '1720296320', '1689740326', '1972746394', '1588989966', '1073777819', '1538492723', '1043461817', '1053354464', '1982989836', '1699811547', '1780857375', '1871787036', '1659365906', '1215953849', '1912976507', '1750365300', '1700862273', '1578528089', '1588629059', '1841297025', '1013987924', '1205816667', '1205844594', '1639149545', '1659531770', '1992892079', '1588698369', '1457323404', '1083904197', '1518971852', '1699838979', '1770557159', '1336180108', '1780689919', '1376500769', '1912944521', '1043215676', '1437233533', '1154559680', '1366599219', '1942203534', '1093914988', '1659387231', '1952482119'])

# result_npis = sorted(['1871787036', '1437233533', '1275714669', '1336180108', '1538492723', '1588989966', '1841297025', '1205844594', '1043461817', '1083904197', '1093914988', '1467407213', '1437398591', '1558362137', '1659365906', '1780689919', '1154559680', '1376500769', '1073777819', '1366599219', '1588629059', '1013987924', '1912976507', '1639225121', '1972746394', '1659387231', '1407912116', '1174560015', '1164566550', '1720296320', '1952482119', '1811968852', '1578528089', '1659531770', '1700862273', '1053354464', '1699811547', '1457323404', '1518971852', '1750365300', '1639149545', '1588698369', '1396951299', '1215953849', '1750546610', '1699838979', '1912944521', '1942203534', '1043215676', '1780857375', '1770557159', '1205816667', '1588648786', '1689740326', '1992892079'])

# print expected_npis
# print result_npis

SQL Statement Generator for Merging Project Tables

# Hello World program in Python
colnames ="""
Project_ID
Project_Name
County
District
Route
Project_Date
Back_Prefix
Back
Ahead_Prefix
Ahead
PM_KP_U
Comments
ModifiedBY
CreatedBY
Modified
tracking_office
tracking_year
tracking_record
status
rejection_comment
reference_number
contact_email
special_instructions
uploaded_date
Loc
create_date
"""
names = colnames.split()
ltable = "geo_projects"
rtable = "geo_projects_20190313_craig"
#print names
for n in names:  
    print "UPDATE " + ltable + " p"
    print "INNER JOIN " + rtable + " pc ON p.ProjectKey = pc.ProjectKey"
    print "SET p." + n + " = pc." + n
    print "WHERE pc." + n + " IS NOT NULL"
    print "  AND TRIM(pc."+n+") != ''"
    print "  AND pc." + n + " != '0000-00-00'"
    print "  AND pc." + n + " != '0000-00-00 00:00:00'"
    print "  AND ( p." + n + " IS NULL OR p." + n + " != pc." + n + " );"
    print
    print "UPDATE " + ltable + " p"
    print "INNER JOIN " + rtable + " pc ON p.ProjectKey = pc.ProjectKey"
    print "SET p." + n + " = NULL"
    print "WHERE (  pc." + n + " IS NULL"
    print "       OR TRIM(pc." + n + ") = ''"
    print "       OR pc." + n + " = '0000-00-00'"
    print "       OR pc." + n + " = '0000-00-00 00:00:00' )"
    print "  AND p." + n + " IS NOT NULL;"
    print
    print "SELECT p." + n + " p_, pc." + n + " pc_"
    print "FROM " + ltable + " p"
    print "INNER JOIN " + rtable + " pc ON p.ProjectKey = pc.ProjectKey;"
    print "-- " + n + " done ----"
    print

Algorithm Example

def f(x):
    return 10-x**2
    

epsilon = 1e-4
fc = 1 
a = 0
b = 10 
fa = f(a)
fb = f(b)
n = 0
while (abs(fc)> epsilon):
    c = (a+b)/2.0
    fc = f(c)
    
    if(fc < 0):
        b = c
    if(fc > 0):
        a = c
    print(c)
    n = n+1
print(c)

SQL Statement Generator for Merging Project Tables Col by Col

# Hello World program in Python
colnames ="""
Project_ID
Project_Name
County
District
Route
Project_Date
Back_Prefix
Back
Ahead_Prefix
Ahead
PM_KP_U
Comments
ModifiedBY
CreatedBY
Modified
tracking_office
tracking_year
tracking_record
status
rejection_comment
reference_number
contact_email
special_instructions
uploaded_date
Loc
create_date
"""
names = colnames.split()
#print names
for n in names:  #
    print "UPDATE geo_projects p"
    print "INNER JOIN geo_projects_20190313_craig pc ON p.ProjectKey = pc.ProjectKey"
    print "SET p." +n+ " = pc." + n
    print "WHERE pc."+n+" IS NOT NULL"
    print "  AND TRIM(pc."+n+") != ''"
    print "  AND pc."+n+" != '0000-00-00'"
    print "  AND pc."+n+" != '0000-00-00 00:00:00'"
    print "  AND ( p."+n+" IS NULL OR p."+n+" != pc."+n+" );"
    print
    print "UPDATE geo_projects p"
    print "INNER JOIN geo_projects_20190313_craig pc ON p.ProjectKey = pc.ProjectKey"
    print "SET p." +n+ " = NULL"
    print "WHERE (  pc."+n+" IS NULL"
    print "       OR TRIM(pc."+n+") = ''"
    print "       OR pc."+n+" = '0000-00-00'"
    print "       OR pc."+n+" = '0000-00-00 00:00:00' )"
    print "  AND p."+n+" IS NOT NULL;"
    print
    print "SELECT p."+n+" p_, pc."+n+" pc_"
    print "FROM geo_projects p"
    
    print "INNER JOIN geo_projects_20190313_craig pc ON p.ProjectKey = pc.ProjectKey;"
    print "-- "+n+" done ----"
    print

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.