# test

unknown
python
2 years ago
2.0 kB
2
Indexable
Never
```# question 4

def getPrimalNumbers(num):
n = num // 2
i = 2
while i < n:
if num % i == 0:
num = num//i
yield i
else:
i+=1

class PrimeGenClass:
def __init__(self, num) -> None:
self.num = num
self.n = num
self.divider = 2
def __iter__(self):
return self
def __next__(self):
while self.divider < self.n:
if self.num % self.divider == 0:
self.num = self.num // self.divider
return self.divider
else:
self.divider += 1
if self.divider > self.n:
raise StopIteration

def blah(*args, **kwargs):
print("ARGS")
for i in list(args):
print(i)
print("KWARGS")
for k in kwargs.keys():
print(kwargs[k])

# Question 5
def upperString(func):
def upperWrapper(*args,**kwargs):
counter = 0
new_args = list(args)
for i,arg in enumerate(new_args):
if isinstance(arg,str):
if new_args[i] !=  arg.upper():
new_args[i] = arg.upper()
counter += 1
new_kwargs = kwargs
for kwarg in new_kwargs.keys():
if isinstance(new_kwargs[kwarg],str):
if new_kwargs[kwarg] != new_kwargs[kwarg].upper():
new_kwargs[kwarg] = new_kwargs[kwarg].upper()
counter += 1
if counter > 0:
print(counter)
return func(*new_args,**new_kwargs)
return upperWrapper

@upperString
def boo(a,b):
print(a,b)

#boo("ASD",b="DFS")

# Question 6 - A

def func(base_num):
return lambda x: x + base_num

# Question 6 - B
def func2(n):
if n < 0:
return
#return func2(n-1) if n > 0 else "Python"
return "Python" if n==0 else lambda : func2(n-1)

print(func2(2)()())```