-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFLA_L3.py
73 lines (50 loc) · 1.23 KB
/
FLA_L3.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
#Ex 1 : Current Time
"""
from datetime import datetime
now = datetime.now()
print(now.strftime("%Y %B %d %H:%M:%S"))
"""
#Ex 2 : Radius of a Circle
"""
import math
radius = float(input("R: "))
print(f"Area is {math.pi * radius**2}")
"""
#Ex 3 : Selecting Random Nb. from a List
"""
import random
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(f"Random nb selected is:", random.choice(l))
"""
#Ex 4: Shuffle Elem. from a List
"""
import random
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
random.shuffle(l)
print(f"Random number shuffled is: ", numbers)
"""
#Ex 5: LCM and GCD with Math Module
"""
import math
a = int(input("a: "))
b = int(input("b: "))
print(f"GCD:", math.gcd(a, b))
print(f"LCM:", abs(a*b) // math.gcd(a, b))
"""
#Ex 6: Factorial Nb. with Math Module
"""
import math
x = int(input("X: "))
print(f"X!:", math.factorial(x))
"""
#Ex 7: Week nb. of a date using isocalendar()
"""
from datetime import datetime
now = datetime.now()
print(f"Week nb:", now.isocalendar()[1])
"""
#Ex 8: Distance btwn. 2 points
import math
x1, y1 = map(float, input("A(x1,y1): ").split())
x2, y2 = map(float, input("B(x2,y2): ").split())
print(f"|A,B|:", math.sqrt((x2 - x1)**2 + (y2 - y1)**2))