Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f73731350e | ||
|
|
73bcfd2e0e | ||
|
|
8db7d11975 | ||
|
|
afcbed5d16 |
@@ -0,0 +1,15 @@
|
|||||||
|
hat_list = [1, 2, 3, 4, 5]
|
||||||
|
|
||||||
|
# passo 1
|
||||||
|
|
||||||
|
hat_list[2] = int(input("Inserisci il nuovo numero centrale: "))
|
||||||
|
|
||||||
|
# passo 2
|
||||||
|
|
||||||
|
del hat_list[-1]
|
||||||
|
|
||||||
|
# passo 3
|
||||||
|
|
||||||
|
print("Lunghezza: ",len(hat_list))
|
||||||
|
|
||||||
|
print(hat_list)
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# passo 1
|
||||||
|
|
||||||
|
beatles = []
|
||||||
|
|
||||||
|
print("Passo 1:", beatles)
|
||||||
|
|
||||||
|
# passo 2
|
||||||
|
|
||||||
|
beatles.append("John")
|
||||||
|
beatles.append("Lennon")
|
||||||
|
beatles.append("Paul")
|
||||||
|
beatles.append("McCartney")
|
||||||
|
beatles.append("Geaorge Harrison")
|
||||||
|
|
||||||
|
print("passo 2:", beatles)
|
||||||
|
|
||||||
|
# passo 3
|
||||||
|
|
||||||
|
for i in range(2):
|
||||||
|
j = input("Inserici un altro membro: ")
|
||||||
|
beatles.append(j)
|
||||||
|
|
||||||
|
print("Passo 3", beatles)
|
||||||
|
|
||||||
|
# passo 4
|
||||||
|
|
||||||
|
for i in range(2):
|
||||||
|
del beatles[-1]
|
||||||
|
|
||||||
|
print("Passo 4", beatles)
|
||||||
|
|
||||||
|
# passo 5
|
||||||
|
|
||||||
|
beatles.insert(0, "Ringo Starr")
|
||||||
|
|
||||||
|
print("Passo 5", beatles)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
my_list = [1, 2, 4, 4, 1, 4, 2, 6, 2, 9]
|
||||||
|
|
||||||
|
unique_list = []
|
||||||
|
|
||||||
|
for number in my_list:
|
||||||
|
if number not in unique_list:
|
||||||
|
unique_list.append(number)
|
||||||
|
|
||||||
|
my_list = unique_list
|
||||||
|
|
||||||
|
print("The list with unique elements only:")
|
||||||
|
print(my_list)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
def is_year_leap(year):
|
||||||
|
if year % 4 == 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
test_data = [1901, 2000, 2016, 1987]
|
||||||
|
|
||||||
|
test_result = [False, True, True, False]
|
||||||
|
|
||||||
|
for i in range(len(test_data)):
|
||||||
|
yr = test_data[i]
|
||||||
|
print(yr, "->", end="")
|
||||||
|
resutl = is_year_leap(yr)
|
||||||
|
|
||||||
|
if resutl == test_result[i]:
|
||||||
|
print("OK")
|
||||||
|
else:
|
||||||
|
print("Failed")
|
||||||
Reference in New Issue
Block a user