-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_ques.py
More file actions
140 lines (107 loc) · 3.48 KB
/
Copy pathpython_ques.py
File metadata and controls
140 lines (107 loc) · 3.48 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# a = 'Nun'
# result = ''.join(list(a)[::-1])
# if a == result:
# print(True)
# else:
# print(False)
# https://www.keka.com/javascript-coding-interview-questions-and-answers
# l = [1,2,3,4,5]
# for i in range(len(l)-1):
# print(i)
# # VS
# l = [1, 2, 3, 4, 5]
# for i in range(len(l)-1):
# print(l[i+1])
# x = "Hello" + 5
# print(x)
# num = 6
# for i in range(2, num):
# if not num % i == 0:
# break
# else:
# print('prime')
l = [[1,3],[4,2]]
s = ''
for i in l:
for j in i:
s = s + str(j)
x = list(s)
# print(max(x),x)
# fibo
num = 10
num_1 = 0
num_2 = 1
for i in range(10):
x = num_1 + num_2
# print(x)
import os
outputs = {}
outputs['current_directory_before'] = os.getcwd()
# print(os.listdir())
log = "July 31 07:51:48 mycomputer bad_process[12345]: ERROR Performing package upgrade"
index = log.index("[")
# print(log[index+1:index+6])
import re
log = "July 31 07:51:48 mycomputer bad_process[12345]: ERROR Performing package upgrade"
regex = r"\[(\d+)\]"
result = re.search(regex, log)
# print(result[1])
import re
# s = 'qwertycatsfruits'
# print(re.search(r'fruits$',s))
# print(re.search(r"p.ng", "Pangaea", re.IGNORECASE))
# Create a regex that finds dates in the format MM/DD/YY or MM/DD/YYYY and returns just the year part.
s = '06-06-2024'
#print('this one:',re.search(r'(\b\d{2}[/-]\d{2}[/-](\d{2}|\d{4})\b)',s))
s = '+91 8884 154409'
indian_pattern_mobile = re.search(r"\d{4} \d{6}",s)
# print(indian_pattern_mobile)
# def to_seconds(hours, minutes, seconds):
# return hours*3600+minutes*60+seconds
# print("Welcome to this time converter")
# cont = "y"
# while(cont.lower() == "y"):
# hours = int(input("Enter the number of hours: "))
# minutes = int(input("Enter the number of minutes: "))
# seconds = int(input("Enter the number of seconds: "))
# print("That's {} seconds".format(to_seconds(hours, minutes, seconds)))
# print()
# cont = input("Do you want to do another conversion? [y to continue] ")
# print("Goodbye!")
# Dear Mrs. Nisha Madam
# I would like to inform you that I am resigning from my position as System Analyst, effective 04-04-2024.
# Thank you for all the support and opportunities you have provided me over the years. I have truly enjoyed my time working at Leads Next Tech and am grateful for the encouragement you have given me to pursue my personal and professional development.
# I will do everything I can to complete my current projects and train other team members or new employees to take over my duties. Please let me know if there is anything else I can do to help during this transition period.
# I wish the company continued success in the future and hope to stay in touch.
# Sincerely,
# Ankur
# Fibonacci Numbers using Native Approach
# n = 10
# num1 = 0
# num2 = 1
# next_number = num2
# count = 1
# while count <= n:
# print(next_number, end=" ")
# count += 1
# # print(num1, num2, next_number)e
# num1, num2 = num2, next_number
# next_number = num1 + num2
# print()
# Find the number of occurrences of a characters in a String?
def count_duplicate(s):
dicti = {}
for i in s:
if i not in dicti:
if s.count(i) > 1:
dicti[i] = s.count(i)
return dicti
st = 'abbsea'
# print(count_duplicate(s))
# How to find out if the given two strings are anagrams or not?
import random
s = 'qwerty'
split_str = list(s)
random.shuffle(split_str)
print(split_str)
# How would you implement the bubble sort algorithm