Demo-ul se poate folosi aici.
Mult mai multe exemple si detalii se pot citi in articolul asta.
Am tiparit:
def reverse_streng(s):
"""reverse the string s"""
A generat:
def reverse_streng(s):
"""reverse the string s"""
result = ""
i = len(s) - 1
while i >= 0:
result = result + s[i]
i = i - 1
return result
def load_tokens(filename):
with open(filename, "r") as f:
for line in f:
tokens = line.strip().split()
for index, word in enumerate(tokens):
tokens[index] = reverse_streng(tokens[index])
return tokens
tokens = load_tokens("input.txt")
output = [tokens[:3] + tokens[3:] + tokens[:6] + tokens[6:] + tokens[:7] + tokens[7:] + tokens[:8] + tokens[8:] + tokens[
Ultima linie este neterminata (asta fiind un demo).
Cele 2 functii insa sunt functionale.
Merge si cu alte tipuri de text.
Am tiparit:
Being a Romanian developer I spend my time on devforum.ro
A generat:
Being a Romanian developer I spend my time on devforum.ro forum helping developers from all around the world with XBMC related questions. Usually I am working in SQL code from my ISP.
I just want to say that thanks to Alexey Veriki I am now a member of Team XBMC. And a thanks to Chris for telling me about devforum.ro.
I used to be member of Team XBMC since the 1st versions and from 7.0 on I worked in every aspect of this project:
0.2.6->0.2.8 to search for a possible hack on MythTV for remote streaming
0.2.6->0.3.0 to insert the UI for mythplayerec
0.2.6->0.3.0 to enhance support for not only music videos but also for music files
0.2.6->0.3.0 to make the playlists re-visitable, sortable and browsable on the fly and with the help of Grooveshark
0.2.6->0.3.0 to remove liblame support and check from up to 10 codecs
0.2.6->0.3.0 to include the HTCond
Am incercat cu ceva un pic mai complex (multiplicare matrici) si - wow - a generat si functia asta. N-am testat-o.
Am tiparit:
def multiply_matrices(a,b):
'''multiplies two matrices a and b and returns result'''
A generat
def multiply_matrices(a,b):
'''multiplies two matrices a and b and returns result'''
if type(a) == type([]):
if type(b) == type([]):
result = []
for i in xrange(len(a)):
for j in xrange(len(b)):
result.append(a[i][j]*b[i][j])
return result
else:
return multiply_matrices(a,b[0])
else:
return multiply_matrices(a,b)
Now you can just call the function without worrying about where the function is located:
In [4]: print(multiply_matrices([[0, 1, 2], [3, 4, 5], [6, 7
[Edit] - am facut asta un thread ptr. toate discutiile legate de AI/ML, sper sa fie ok ptr. moderatori.