-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA Practice.py
More file actions
39 lines (28 loc) · 789 Bytes
/
DSA Practice.py
File metadata and controls
39 lines (28 loc) · 789 Bytes
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
import time
def check_odd_even(number):
if number % 2 == 0:
return "Even"
else:
return "Odd"
# Get user input
user_input = int(input("Enter a number: "))
# Check if the number is odd or even
result = check_odd_even(user_input)
# Display the result
print(f"The number {user_input} is {result}.")
# TIme efficency
start = time.time()
for i in range(1, 100):
print(i)
print("Time Calculated to print number is ", time.time() - start)
# algorithm
n = 40
print(n * n) # n square means 40 into 40
# constant time
i = {'Umang', 'shivansh', 'shaurya'}
print(i.__len__())
# Reverse String Tecxhnique
def my_function(x):
return x[::-1]
mytxt = my_function("I wonder how this text looks like backwards")
print(mytxt)