0% found this document useful (0 votes)
7 views

py

Uploaded by

preeeti250
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)
7 views

py

Uploaded by

preeeti250
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
You are on page 1/ 3

[[ 6 8 10 11]

[ 6 8 10 11]]
[[-4 -4 -4 -3]
[-4 -4 -4 -3]]
[[ 5 12 21 28]
[ 5 12 21 28]]
[[0 0 0 0]
[0 0 0 0]]
[[1 2 3 4]
[1 2 3 4]]
[[ 1 64 2187 16384]
[ 1 64 2187 16384]]

2 4
1 2 3 4
1 2 3 4
5 6 7 7
5 6 7 7

N, M = map(int, input().split(' '))

a = [numpy.array((input().split(' ')), dtype='int') for i in range(N)]


b = [numpy.array((input().split(' ')), dtype='int') for j in range(N)]

N = [numpy.array((input().split()),dtype='int') for i in range(n)]

N = [numpy.array(input().split(),dtype='int') for i in range(1)]

print(' '.join(map(str,Y)))

print(*result)
itertools.product->cartesian product
iterdools.permutations
from collections import Counter
from collections import defaultdict->if no key then it will not give error
OrderDict

Nice code:
rsplit(maxsplit=1)
d[n] = d[n] + int(c) if n in d else int(c)
[print(''.join(tup_pair)) for tup_pair in sorted(list(permutations(string,
length)))]

doubts:
exec(f"d.{l[0]}({l[1]})")->what is f????
getattr()->?
ex:input_command = getattr(my_deque, split_input[0])->see gallery on 09.05.2024

s = input()
letters = {}
for i in s:
letters[i] = letters.get(i, 0) + 1

from collections import deque


d=deque()
for _ in range(int(input())):
x=list(input().split())
if len(x)>1:
eval(d.x[0](x[1]))
else:
eval(d.x[0])
print(d)
---------
counter = {c : s.count(c) for c in s}

counter = sorted(counter.items(), key=lambda x: (-x[1], x[0]))[:3]->doubt(clarified


# default is ascending order so negate the counts)

for i in counter:
print(" ".join(map(str, i)))

SOLVE:
Collections->Piling Up

Yes
No
Yes

for _ in range(int(input())):
n = int(input())
d = deque(map(int, input().split()))
flag = 'Yes'
while len(d) > 1:
a = d.popleft() if d[0] >= d[-1] else d.pop()
if a < max(d[0], d[-1]):
flag = 'No'
break
print(flag)
text wrap:(its import textwrap)->learn more abt it
designer door mat->see this code(i have not seen yet)
n,m = list(map(int, input().split()))

s = ".|."
h = "-"
w = "WELCOME"

pat = [(s*(2*i + 1)).center(m, h) for i in range(n//2)]


wel = [w.center(m,h)]

x = "\n".join(pat+wel+pat[::-1])
print(x)

and
N, M = map(int, input().split())

if N%2 != 0 and 5 < N < 101 and 15 < M < 303:


for i in range(1, N, 2):
print((".|."*i).center(M, "-"))

print("WELCOME".center(M, "-"))

for j in range(N-2, -1, -2):


print((".|." *j).center(M, "-"))
string-validators:
print(any(c.isalnum() for c in s))``
print(any(c.isalpha() for c in s))
print(any(c.isdigit() for c in s))
print(any(c.islower() for c in s))
print(any(c.isupper() for c in s))

print(any([x.isalnum() for x in s]))


print(any([x.isalpha() for x in s]))
print(any([x.isdigit() for x in s]))
print(any([x.islower() for x in s]))
print(any([x.isupper() for x in s]))
def split_and_join(line):
return "-".join(line.split(" "))

l=list(string)
l[position]=character
print(''.join(l))
#return ''.join(l)

#learn more abt fromkeys()


used in merge_the_tools:
def merge_the_tools(string, k):
S=[]
l=[]
l.extend(tp.wrap(string,k))
for i in l:
print("".join(dict.fromkeys(i)))
foo = "mppmt"
result = "".join(dict.fromkeys(foo))

TFuck
for i in range(1, number+1):
width = len(f"{number:b}")
print(f"{i:>{width}d} {i:>{width}o} {i:>{width}X} {i:>{width}b}")

You might also like