Hey, and thank you for this exercises! I just completed ZTM's Python Developer course and started doing this exercises a few days ago. It really helps with becoming more fluent in python .
Just thought I'd share a few of my solutions and you see if any of them are worthy of adding. (Hope I'm posting this in the right section)
EXERCISE 7
def buid_array(x, y):
main = []
for i in range(x):
main.append([])
for j in range(y):
main[i].append(i*j)
buid_array(3, 5)
EXERCISE 3
def my_dict(n):
my_dict = {}
for i in range(1, n+1):
my_dict.update({i: i*i})
print(my_dict)
my_dict(10)
EXERCISE 2
from math import factorial
def my_factorials(*nums):
li = []
for i in nums:
li.append(str(factorial(i)))
results = ','.join((li))
print(results)
my_factorials(1, 2, 3, 4, 5, 6, 7, 8)
Hey, and thank you for this exercises! I just completed ZTM's Python Developer course and started doing this exercises a few days ago. It really helps with becoming more fluent in python .
Just thought I'd share a few of my solutions and you see if any of them are worthy of adding. (Hope I'm posting this in the right section)
EXERCISE 7
def buid_array(x, y):
main = []
for i in range(x):
main.append([])
for j in range(y):
main[i].append(i*j)
buid_array(3, 5)
EXERCISE 3
def my_dict(n):
my_dict = {}
for i in range(1, n+1):
my_dict.update({i: i*i})
print(my_dict)
my_dict(10)
EXERCISE 2
from math import factorial
def my_factorials(*nums):
li = []
for i in nums:
li.append(str(factorial(i)))
results = ','.join((li))
print(results)
my_factorials(1, 2, 3, 4, 5, 6, 7, 8)