Esempio n. 1
0
import code

a_list =[1,2,3]

another_list =["harry", "ron", "hermione"]
yanother_list = [1,"harry", 3.4,"blue"]

the_sum = code.my_sum(a_list)
# print(the_sum)

the_prod = code.my_prod(a_list)
# print(the_prod)

the_count = code.my_count(a_list)
# print(the_count)

print(code.get_filenames('C:\\Users\\JuliaMB\\Desktop\\hermine\\pythoncode'))

#
Esempio n. 2
0
# total is called accumulated variable. it is updated every time the for loop is updated


#exercise 3: print one number which is the multiplication of the numbers in the list

g=[12,3,12]
totalm=1
for m in g:
    totalm = m * totalm

print(totalm)

#exercise 4: call the function in code.py, call it in a new way and
import code 
the_sum = code.my_sum(a)
print(the_sum)

# exercise 5: call the function in code.py for products
the_product = code.my_product(a)
print(the_product)

#exercise 6: I have to know how many elements you have in a list
the_count = code.my_count(a)
print(the_count)

#exercise 7: write a function that counts the number of items smaller than 5
the_count_less_than_5 = code.my_count_less_than_5(a)
print(the_count_less_than_5)

#exercise 8: write a function that counts the number of ones in a list