7th day of python challenges 96-103

This commit is contained in:
abd.shallal
2019-07-31 14:12:40 +03:00
parent 4b84e9882a
commit dc946b9aba
11 changed files with 296 additions and 156 deletions

View File

@@ -0,0 +1 @@
array_list = [[2, 5, 8], [3, 7, 4], [1, 6, 9], [4, 2, 0]]

View File

@@ -0,0 +1,7 @@
array_list = [[2, 5, 8], [3, 7, 4], [1, 6, 9], [4, 2, 0]]
print(' row0 row1 row2')
for i in array_list:
print('column', i)
column = int(input('Please select a COLUMN from array above : '))
row = int(input('Please select a ROW number from array above : '))
print('the value in [{0}][{1}] = {2}'.format(row, column, array_list[column][row]))

View File

@@ -0,0 +1,11 @@
array_list = [[2, 5, 8], [3, 7, 4], [1, 6, 9], [4, 2, 0]]
print(' row0 row1 row2')
for i in array_list:
print('column', i)
row_ask = int(input('Enter row number to display? : '))
print(array_list[row_ask])
add_ask = int(input('Enter number to add to array : '))
array_list[row_ask].append(add_ask)
print(' row0 row1 row2')
for i in array_list:
print('column', i)

View File

@@ -0,0 +1,15 @@
array_list = [[2, 5, 8], [3, 7, 4], [1, 6, 9], [4, 2, 0]]
print(' row0 row1 row2')
for i in array_list:
print('column', i)
row_ask = int(input('Enter row number to display? : '))
print(array_list[row_ask])
column_ask = int(input('Enter column number in row to display? : '))
print(array_list[row_ask][column_ask])
user_ask = str(input('Would like to change value of this position? yes|no : '))
if user_ask == 'yes':
edit_ask = int(input('Enter number to add to array : '))
array_list[row_ask][column_ask] = edit_ask
print(' row0 row1 row2')
for i in array_list:
print('column', i)

View File

@@ -0,0 +1,6 @@
array_list = {
'John': {'N': 3056, 'S': 8463, 'E': 8441, 'W': 2694},
'Tom': {'N': 4832, 'S': 6786, 'E': 4737, 'W': 3612},
'Anne': {'N': 5239, 'S': 4802, 'E': 5820, 'W': 1859},
'Fiona':{'N': 3904, 'S': 3645, 'E': 8821, 'W': 2451}
}

View File

@@ -0,0 +1,18 @@
array_list = {
'John': {'N': 3056, 'S': 8463, 'E': 8441, 'W': 2694},
'Tom': {'N': 4832, 'S': 6786, 'E': 4737, 'W': 3612},
'Anne': {'N': 5239, 'S': 4802, 'E': 5820, 'W': 1859},
'Fiona': {'N': 3904, 'S': 3645, 'E': 8821, 'W': 2451}
}
print('Regions are : N, S, E, W')
print('Names Are : ')
for i in array_list:
print(i)
region_ask = str(input('Please enter region : ')).upper()
name_ask = str(input('Please enter name : ').capitalize())
print(array_list[name_ask][region_ask])
user_ask = str(input('Would like to change value of this position? yes|no : '))
if user_ask == 'yes':
edit_ask = int(input('Enter number to replace for this position : '))
array_list[name_ask][region_ask] = edit_ask
print(array_list[name_ask])

View File

@@ -0,0 +1,12 @@
array_list = {}
for i in range(4):
name = str(input('Enter name to add : '))
age = int(input('Enter age to add : '))
shoe_size = int(input('Enter shoe size to add : '))
array_list[name] = {}
array_list[name]['age'] = age
array_list[name]['shoe_size'] = shoe_size
for i in array_list:
print(i)
name_ask = str(input('Enter name to show : '))
print(array_list[name_ask])

View File

@@ -0,0 +1,10 @@
array_list = {}
for i in range(4):
name = str(input('Enter name to add : '))
age = int(input('Enter age to add : '))
shoe_size = int(input('Enter shoe size to add : '))
array_list[name] = {}
array_list[name]['age'] = age
array_list[name]['shoe_size'] = shoe_size
for i in array_list:
print(i, array_list[i]['age'])

View File

@@ -0,0 +1,14 @@
array_list = {}
for i in range(4):
name = str(input('Enter name to add : '))
age = int(input('Enter age to add : '))
shoe_size = int(input('Enter shoe size to add : '))
array_list[name] = {}
array_list[name]['age'] = age
array_list[name]['shoe_size'] = shoe_size
for i in array_list:
print(i)
name_ask = str(input('Enter name to remove : '))
del array_list[name_ask]
for i in array_list:
print(i)