-
Notifications
You must be signed in to change notification settings - Fork 6
/
common modules used in python.py
98 lines (69 loc) · 1.59 KB
/
common modules used in python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Q1:- What is Time Tuple?
''' time tupples are used to access various time
these are:
import time
print(time.time())
print(time.asctime())
print(time.gmtime())
print(time.perf_counter())
print(time.localtime())
print(time.ctime())
print(time.timezone) '''
##############
#Q.2 Write a program to get formatted time
'''
import time
import os
while True:
print(time.strftime("%H:%M:%S"))
time.sleep(1)
os.system('cls')
'''
##############
#Q.3 Extract month from the time
'''
import datetime
a="28-8-2018"
b=datetime.datetime.strptime(a,"%d-%m-%Y")
print(b.month)
'''
##############
#Q.4 Extract day from the time
'''
import datetime
a="28-8-2018"
b=datetime.datetime.strptime(a,"%d-%m-%Y")
print(b.day)
'''
##############
#Q.5 Extract date (ex : 11 in 11/01/2021) from the time.
'''
import datetime
a=datetime.date.today()
print(a)
'''
###############
#Q.6 Write a program to print time using localtime method
'''
import time
a=time.localtime()
print(a)
'''
################
#Q.7 Find the factorial of a number input by user using math package functions.
'''
import math
a=int(input("enter no of which you want factorial: "))
a=math.factorial(a)
print(a)
'''
##################
#Q.8 Find the GCD of a number input by user using math package functions.
"""
import math
a=int(input("enter 1st number : "))
b=int(input("enter second number : "))
c=math.gcd(a,b)
print( " \t \" ", c , " \" ", " \n This is the greatest common divisior of ","\"",a,"\"","and","\"",b,"\"")
'''
################## END