PythonPackagesandData Accesss
PythonPackagesandData Accesss
Function Description
os.name Provides the name of the operating system. Examples of registered
names are 'posix', 'nt', 'os2', 'ce', 'java'.
os.close() To close a file.
os.popen() Provides a pipe or gateway through which files can be accessed
directly. Contains two modes; 'r' to read, and 'w' to write. If nothing is
specified, the default mode is 'r'.
os.mknod() To create a file. For example, os.mknod ("file_name.txt") will create a
file.
os.error() Raises an OSError when an invalid path or file name is given.
os.chdir() To change a directory to a specified path. For example, os.chdir ('New
directory path').
import sys
import os
import io
def func1(a):
sys.stdout.write(a)
s = 1
return s
if __name__ == "__main__":
try:
data=input()
b=func1(data)
except ValueError as error:
print(False)
s = os.getcwd()
os.mkdir("New Folder")
time.sleep(6)
os.chdir("/projects/challenge/New Folder")
time.sleep(6)
q = os.getcwd()
os.chdir("/projects/challenge/")
os.rename("New Folder", "New Folder2")
time.sleep(6)
os.chdir("/projects/challenge/New Folder2")
time.sleep(6)
p = os.getcwd()
os.chdir("/projects/challenge/")
os.rmdir('New Folder2')
time.sleep(6)
w = os.getcwd()
import os
import datetime
def func1(y,m,d,ms,se,da,mi):
input_date = datetime.date(y, m, d)
input_date1 = datetime.datetime.combine(input_date,datetime.time(ms, se, da,
mi))
t = input_date1 - datetime.timedelta(microseconds = 1, seconds = 2, days = 3,
minutes = 2 )
day = t.day
year= t.year
month = t.month
minute= datetime.datetime.strptime(t.strftime("%Y-%m-%d %H:%M:%S.%f"), "%Y-%m-
%d %H:%M:%S.%f").minute
second= datetime.datetime.strptime(t.strftime("%Y-%m-%d %H:%M:%S.%f"), "%Y-%m-
%d %H:%M:%S.%f").second
return input_date,input_date1,t,day,year,month,minute,second
def func2(y,m,d,ms,se,da,mi):
s = "%a %B %d %H %M: %S %Y"
x = datetime.datetime (y,m,d,ms,se,da,mi)
q = x.strftime(s)
z = datetime.datetime.strptime(q,s)
return x,q,z
if __name__ == "__main__":
y,m,d,ms,se,da,mi = map(int, input().split())
inputs=func1(y,m,d,ms,se,da,mi)
inputs5=func2(y,m,d,ms,se,da,mi)
print(inputs[0])
print(inputs[1])
print(inputs[2])
print(inputs[3])
print(inputs[4])
print(inputs[5])
print(inputs[6])
print(inputs[7])
print(inputs5[0])
print(inputs5[1])
print(inputs5[2])
Input (stdin)
2020 5 9 1 2 3 4
Your Output (stdout)
2020-05-09
2020-05-12
2020-05-09
9
2020
5
0
0
2020-05-09 01:04:02.000003
Sat May 09 01 04:02 2020
2020-05-09 01:04:02
Expected Output
2020-05-09
2020-05-09 01:02:03.000004
2020-05-06 01:00:01.000003
6
2020
5
0
1
2020-05-09 01:02:03.000004
Sat May 09 01 02: 03 2020
2020-05-09 01:02:03
import os
import shutil
# Source path
source = "/projects/challenge/New Dir/newww.txt"
# Destination path
destination = "/projects/challenge/"