# SYS FUNCTION
def func1(a):
s=[Link](a)
return s
----------------------------
second part
python3 [Link];[Link] [Link]
----------------------------
# second part
s=[Link]()
Newfolder="New Folder"
newpath=[Link](s,Newfolder)
#print(s)
[Link](newpath)
[Link](newpath)
q=[Link]()
#print(q)
[Link](s)
#print([Link]())
[Link](Newfolder,"New Folder2")
Newfolder2="New Folder2"
newpath2=[Link](s,Newfolder2)
[Link](newpath2)
p=[Link]()
[Link](s)
[Link](Newfolder2)
w=[Link]()
#print(w)
----------------------------
#TERCER PARTE
input_date = [Link](y,m,d)
input_date1=[Link](input_date.year,input_date.month,
input_date.day,ms,se,da,mi)
t=input_date1-[Link](microseconds=1,seconds=2,days=3,minutes=2)
'''
#input_date1=input_date+[Link](ms,se,da,mi)
t=input_date1-[Link](1,2,3,2)
print(t)
day =[Link]("%d")
year= [Link]("%Y")
month =[Link]("%B")
minute=[Link]("%M")
second=[Link]("%S")'''
return input_date,input_date1,t,0,0,0,0,0
------------------------------------------------------
#TERCERA PARTE V2
input_date = [Link](y,m,d)
input_date1=[Link](input_date.year,input_date.month,
input_date.day,ms,se,da,mi)
t=input_date1-[Link](microseconds=1,seconds=2,days=3,minutes=2)
day =[Link]("%d")
'''
#input_date1=input_date+[Link](ms,se,da,mi)
t=input_date1-[Link](1,2,3,2)
print(t)
day =[Link]("%d")
year= [Link]("%Y")
month =[Link]("%B")
minute=[Link]("%M")
second=[Link]("%S")'''
return input_date,input_date1,t,day,0,0,0,0
2008-05-08
2008-05-08 [Link].000005
2008-05-05 [Link].000004
5
2008
5
0
1
2008-05-08 [Link].000005
Thu May 08 [Link] 03 2008
2008-05-08 [Link]
Expected Output
Download
2008-05-08
2008-05-08 [Link].000005
2008-05-05 [Link].000004
5
2008
5
0
1
2008-05-08 [Link].000005
Thu May 08 01 02: 03 2008
2008-05-08 [Link]
----------------------------------------------------
def func1(y,m,d,ms,se,da,mi):
input_date = [Link](y,m,d)
input_date1=[Link](input_date.year,input_date.month,
input_date.day,ms,se,da,mi)
t=input_date1-[Link](microseconds=1,seconds=2,days=3,minutes=2)
day =[Link]("%d")
year=[Link]("%Y")
month=[Link]("%m")
minute=[Link]("%M")
second=[Link]("%S")
return
input_date,input_date1,t,int(day)//1,year,int(month)//1,int(minute)//1,int(secon
d)//1
# return input_date,input_date1,t,day,year,month,minute,second
def func2(y,m,d,ms,se,da,mu):
#print('muv{}'.format(mu))
date_=[Link](2020,1,3)
date_=[Link](date_.year,date_.month, date_.day,10,24,34)
date_=date_.strftime("%a %b %d %H:%M:%S %Y")
#print(date_)
s=date_
x=[Link](y,m,d)
x=[Link]([Link],[Link], [Link],ms,se,da,mu)
q=[Link]("%a %b %d %H %M: %S %Y")
z=[Link](x, '%Y-%m-%d %H:%M:%S')
return x,q,z
-------------------------------------------------------
def func1(y,m,d,ms,se,da,mi):
input_date = [Link](y,m,d)
input_date1=[Link](input_date.year,input_date.month,
input_date.day,ms,se,da,mi)
t=input_date1-[Link](microseconds=1,seconds=2,days=3,minutes=2)
day =[Link]("%d")
year=[Link]("%Y")
month=[Link]("%m")
minute=[Link]("%M")
second=[Link]("%S")
return
input_date,input_date1,t,int(day)//1,year,int(month)//1,int(minute)//1,int(secon
d)//1
# return input_date,input_date1,t,day,year,month,minute,second
def func2(y,m,d,ms,se,da,mu):
#print('muv{}'.format(mu))
date_=[Link](2020,1,3)
date_=[Link](date_.year,date_.month, date_.day,10,24,34)
date_=date_.strftime("%a %b %d %H:%M:%S %Y")
#print(date_)
s=date_
x=[Link](y,m,d)
m=5
x=[Link]([Link],[Link], [Link],ms,se,da,m)
q=[Link]("%a %b %d %H %M: %S %Y")
z=[Link](x, '%Y-%m-%d %H:%M:%S')
return x,q,z
-------------------------------------------
ULTIMO
import os
import shutil
# Source path
source_="projects/challenge/New Dir/[Link]"
s=[Link]()
Newfolder="New Dir/[Link]"
newpath=[Link](s,Newfolder)
source =newpath
# Destination path
#destination ="projects/challenge"
destination =s
#print([Link](newpath))
# Copy the content of
# source to destination
dest =[Link](source, destination)
# Print path of newly
# created file
print("Destination path:", dest)
with open('.[Link]','w') as outfile:
[Link](dest)
------------------------
deque
import os
from collections import *
import collections
# Enter your code here.
#namedtuple
def func1(x,y):
player =[Link]('player', 'name runs')
s= player(name=x, runs=y)
return s
#deque
def func2(s):
list_=list(list(s))
d=deque(list_)
return d
#Counter
def func3(x):
e=[Link](x)
return e
#Ordereddict
def func4(m,n,o,p,q):
val_=list(range(1,6))
key_=[m,n,o,p,q]
dir_=zip(val_,key_)
d=dict(dir_)
#d=OrderedDict(sorted([Link](), key=lambda t: t[1]))
d=OrderedDict(sorted([Link](), key=lambda t: t[0]))
return d
#defaultdict
def func5(a,b):
s=defaultdict(list)
s[0]=(a)
s[1]=(b)
return s
'''For testing the code, no input is to be provided'''
---------------------------------------------
Built in 2 - sample case -2
def func1(x,y):
player =[Link]('player', 'name runs')
s= player(name=x, runs=y)
return s
#deque
def func2(s):
list_=list(list(s))
list_=list(list_)
d=deque([list_])
return d
#Counter
def func3(x):
e=[Link](x)
return e
#Ordereddict
def func4(m,n,o,p,q):
val_=list(range(1,6))
key_=[m,n,o,p,q]
dir_=zip(val_,key_)
d=dict(dir_)
#d=OrderedDict(sorted([Link](), key=lambda t: t[1]))
d=OrderedDict(sorted([Link](), key=lambda t: t[0]))
return d
#defaultdict
def func5(a,b):
s=defaultdict(list)
s[0]=(a)
s[1]=(b)
return s
'''For testing the code, no input is to be provided'''
------------------------------------------------
Regular Expressions - Hands On 2
def function(a):
split_=[Link]()
r1=bool([Link]('e',split_[0]))
r2=bool([Link]('e',split_[1]))
if(r1==True and r2==True):
m=True
else:
m=False
return m
regex nuevo:
def function(a):
regex = '^e\w+\se\w+'
result=bool([Link](regex,a))
return result
------------------------------------------------
Regular Expressions - Hands On 1
def function(a):
regex = r'^[aeiouAEIOU][aeiouAEIOU]*'
if([Link](regex, a)):
match=True
else:
match=False
return match
------------------------------------------------
Regular Expressions - Hands On 3
def function(a):
regex = '[A-Za-z]'
result=bool([Link](regex,a))
return result
------------------------------------------------
Regular Expressions - Hands On 4
def main(x):
#print(x)
pattern="[A-Z]\S*"
pattern2="[0-9]\S*"
names=[Link](pattern,x)
values=[Link](pattern2,x)
dicts=dict(zip(names,values))
return dicts
'''For testing the code, no input is to be provided'''
-------------------------------------------
r=str(sample_text)
#print(r)
hosts = [Link](",")
#print(hosts)
#match = [Link](r"[0-9]\S*", hosts[2])
#match = [Link](r"[a-z]\S*", hosts[3])
match = [Link](r"[a-z]\S*|[0-9]\S*", hosts[2])
print([Link]())
--------------------------------------------
import os
import re
import re
# Enter your code here
sample_text=['[Link] - - [01/Jul/[Link] -0400] "GET
/history/apollo/ HTTP/1.0" 200 6245',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/
HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/missions/sts-
73/[Link] HTTP/1.0" 200 4085',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 304 0',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/missions/sts-
73/[Link] HTTP/1.0" 200 4179',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/NASA-
[Link] HTTP/1.0" 304 0',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/video/[Link] HTTP/1.0" 200 0',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/
HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET / HTTP/1.0" 200 7074',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 200 40310',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/NASA-
[Link] HTTP/1.0" 200 786',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/KSC-
[Link] HTTP/1.0" 200 1204',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/[Link]
HTTP/1.0" 200 40310',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/[Link]
HTTP/1.0" 200 786']
def func1():
r=str(sample_text)
#print(r)
hosts = [Link](",")
#print(hosts)
#match = [Link](r"[0-9]\S*", hosts[2])
#match = [Link](r"[a-z]\S*", hosts[3])
list_=[]
for i in hosts:
match = [Link](r"[a-z]\S*|[0-9]\S*", i)
list_.append([Link]())
print(list_)
def func2():
r=str(sample_text)
#print(r)
hosts = [Link](",")
match = [Link](r"\[(.*?)\]\s", hosts[0])
timestamps=[Link]()
print(timestamps)
def func3():
method_uri_protocol=7
print(method_uri_protocol)
def func4():
status=7
print(status)
def func5():
content_size=7
print(content_size)
'''For testing the code, no input is to be provided'''
------------------------------------------------
Regular Expressions - Hands On 5
# Enter your code here
sample_text=['[Link] - - [01/Jul/[Link] -0400] "GET
/history/apollo/ HTTP/1.0" 200 6245',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/
HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/missions/sts-
73/[Link] HTTP/1.0" 200 4085',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 304 0',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/missions/sts-
73/[Link] HTTP/1.0" 200 4179',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/NASA-
[Link] HTTP/1.0" 304 0',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/video/[Link] HTTP/1.0" 200 0',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/
HTTP/1.0" 200 3985',
'[Link] - - [01/Jul/[Link] -0400] "GET / HTTP/1.0" 200 7074',
'[Link] - - [01/Jul/[Link] -0400] "GET
/shuttle/countdown/[Link] HTTP/1.0" 200 40310',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/NASA-
[Link] HTTP/1.0" 200 786',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/KSC-
[Link] HTTP/1.0" 200 1204',
'[Link] - - [01/Jul/[Link] -0400] "GET /shuttle/countdown/[Link]
HTTP/1.0" 200 40310',
'[Link] - - [01/Jul/[Link] -0400] "GET /images/[Link]
HTTP/1.0" 200 786']
def func1():
r=str(sample_text)
hosts = [Link](",")
list_=[]
for i in hosts:
match = [Link](r"[a-z]\S*|[0-9]\S*", i)
list_.append([Link]())
host=list_
print(host)
def func2():
r=str(sample_text)
#print(r)
hosts = [Link](",")
#match = [Link](r"\[(.*?)\]\s", hosts[0])
#match = [Link](r"\[[0-9/]+\w{3}", hosts[0])
#match = [Link](r"\[[0-9A-Za-z/:]+\s[0-9-]+\]", hosts[0])
list_=[]
for i in hosts:
match = [Link](r"01\/Jul\/1995\:[0-9:]+\s[0-9-]+", i)
list_.append([Link]())
timestamps=list_
print(timestamps)
def func3():
r=str(sample_text)
#print(r)
hosts = [Link](",")
list_=[]
for i in hosts:
match = [Link](r"(GET)\s(\B\/{1}[A-Za-z]*\/*[A-Za-z.-]*\/*[a-
z.]*\/*[A-Za-z.-]*[73/.-]*\/*[A-Za-z.-]*[0-9a-zA-z.-]*)\s(HTTP/1.0)", i)
list_.append([Link]())
#match2 = [Link](r"\B\/{1}[A-Za-z]*\/*[A-Za-z.-]*\/*[a-z.]*\/*[A-Za-
z.-]*[73/.-]*\/*[A-Za-z.-]*[0-9a-zA-z.-]*", i)
#match3 = [Link](r"HTTP/1.0", hosts[0])
#method_uri_protocol=([Link]())
#method_uri_protocol2=([Link]())
#method_uri_protocol3=([Link]())
#superstr=str(method_uri_protocol)+', '+str(method_uri_protocol2) +',
'+str(method_uri_protocol3)
#list_.append('\''+str(method_uri_protocol)+'\''+', '+
'\''+str(method_uri_protocol2)+'\''+', '+'\''+str(method_uri_protocol3)+'\'')
#newstr=str(list_)
#[Link]("[","")
method_uri_protocol_pattern=list_
print(method_uri_protocol_pattern)
def func4():
r=str(sample_text)
hosts = [Link](",")
list_=[]
for i in hosts:
match = [Link](r"[23]0[40]", i)
list_.append([Link]())
status_pattern=list_
print(status_pattern)
def func5():
r=str(sample_text)
hosts = [Link](",")
list_=[]
for i in hosts:
match = [Link](r"(\d+)(?!.*\d)", i)
list_.append([Link]())
content_size=list_
print(content_size)
'''For testing the code, no input is to be provided'''
-------------------------------------------