-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandbox.py
39 lines (33 loc) · 850 Bytes
/
sandbox.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
#schimbare caracter recursive
""" st = "addddssa"
ch1 = "d"
ch2 = "x"
def replace_char(st, charToFind,charToReplace):
if len(st) > 0:
if st[0] == charToFind:
return charToReplace + replace_char(st[1:], charToFind, charToReplace)
else:
return st[0] + replace_char(st[1:], charToFind, charToReplace)
else:
return ""
print(replace_char(st,ch1,ch2))
"""
#sterge impare
""" list = [1,2,3,4,5,6,7,8,9]
newlist = [el for el in list if el%2==0]
print(newlist) """
#sumanrnat
""" def suma_nrnat(n):
if n == 0:
return n
else:
return n + suma_nrnat(n-1)
print(suma_nrnat(5)) """
#produsnrnat
""" def produs_nrnat(n):
if n == 1:
return n
else:
return n * produs_nrnat(n-1)
print(produs_nrnat(4)) """
#