Python Packages and Data Access Fresco Play Handson Solutions

 Python Packages and Data Access Fresco Play Handson Solutions

Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.


Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)


1.Python Built-in Packages - Hands-on 1

Welcome to Python Built-In Packages-1


1.1)Python Built-In Package-SYS



import sys

import os

import io


def func1(a):

    s=sys.stdout.write(a)

    return s


if __name__ == "__main__":


1.2)Python Built-In Package-OS


import os

#Write your code here


s = os.getcwd()

os.mkdir('New Folder')

os.chdir(r'./New Folder')

q = os.getcwd()

os.chdir(s)

os.rename('New Folder','New Folder2')

os.chdir(r'./New Folder2')

p = os.getcwd()

os.chdir(s)

os.rmdir('New Folder2')

w = os.getcwd()




with open('.hidden.txt','w'as outfile:

     outfile.write(s)

with open('.hidden1.txt''w'as outfile:

     outfile.write(q)

with open('.hidden2.txt''w'as outfile:

     outfile.write(p)

with open('.hidden3.txt''w'as outfile:

     outfile.write(w)


1.3)Python Built-In Package-DATETIME


import os

import datetime


def func1(y,m,d,ms,se,da,mi):


    input_date = datetime.date(y,m,d)

    input_date1= datetime.datetime(y,m,d,ms,se,da,mi)

    t= input_date1 - datetime.timedelta(days=3,minutes=2,seconds=2,microseconds=1)

    day = t.day

    year= t.year

    month = t.month

    minute= t.minute

    second= t.second 

    return input_date,input_date1,t,day,year,month,minute,second

def func2(y,m,d,ms,se,da,mi):

    input_date2 = datetime.datetime(2020,1,3,10,34,24)

    f = "%a %b %d %H %M: %S %Y"

    s= input_date2.strftime(f)

    x= datetime.datetime(y,m,d,ms,se,da,mi)

    q= x.strftime(f)

    z= datetime.datetime.strptime(q,f)

    return x,q,z


if __name__ == "__main__":


1.4)Python Built-In Package-SHUTIL


import os 

import shutil 

# Source path 

source = (r'/projects/challenge/New Dir/newww.txt')

  

# Destination path 

destination = (r'/projects/challenge')

  

# Copy the content of 

# source to destination 

dest = shutil.copy(source,destination)

  

  

# Print path of newly  

# created file 

print("Destination path:", dest) 



with open('.hidden.txt','w'as outfile:

  outfile.write(dest)

  


Comments

popular posts