0% found this document useful (0 votes)
194 views2 pages

Python Date and Time Function Guide

The document contains a Python script that defines a function 'dateandtime' which processes date and time based on an integer input value. Depending on the value, it can return a date object, formatted date string, time object, or various date-related information. The script also includes input handling to gather parameters for the function from the user.

Uploaded by

arif895178
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views2 pages

Python Date and Time Function Guide

The document contains a Python script that defines a function 'dateandtime' which processes date and time based on an integer input value. Depending on the value, it can return a date object, formatted date string, time object, or various date-related information. The script also includes input handling to gather parameters for the function from the user.

Uploaded by

arif895178
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#!

/bin/python3

import math
import os
import random
import re
import sys

import datetime
#
# Complete the 'dateandtime' function below.
#
# The function accepts INTEGER val as parameter.
# The return type must be LIST.
#

def dateandtime(val,tup):
# Write your code here
li=list()
if(val==1):
year=tup[0]
month=tup[1]
day=tup[2]
[Link]([Link](year,month,day))
x=[Link](year,month,day)
[Link]([Link]("%d/%m/%Y"))
return li
elif(val==2):
a=tup[0]
[Link]([Link](a))
return li
elif(val==3):
h=tup[0]
m=tup[1]
s=tup[2]
[Link]([Link](h,m,s))
x=[Link](h,m,s)
[Link]([Link]("%I"))
return li
elif(val==4):
year=tup[0]
month=tup[1]
day=tup[2]
x=[Link](year,month,day)
[Link]([Link]("%A"))
[Link]([Link]("%B"))
[Link]([Link]("%j"))
return li
elif(val==5):
year=tup[0]
month=tup[1]
day=tup[2]
h=tup[3]
m=tup[4]
s=tup[5]
[Link]([Link](year,month,day,h,m,s))
return li
if __name__ == '__main__':
val = int(input().strip())

if val ==1 or val==4 or val ==3:


qw1_count=3
if val==2:
qw1_count=1
if val ==5:
qw1_count=6
qw1 = []

for _ in range(qw1_count):
qw1_item = int(input().strip())
[Link](qw1_item)

tup=tuple(qw1)

ans = dateandtime(val,tup)

print(ans)

You might also like