Добавил:
chrysler_a57_mltbnk
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:семестр 1 / lab5
.py import os
clear = lambda: os.system('cls')
clear()
val_s = 'Aleksey'
val_i = 5
val_f = 1.2
val_b = 50 < 7
val_nb = not val_b
l = [['val_s ','val_i ','val_f ','val_b ','val_nb'],[val_s,val_i,val_f,val_b,val_nb]] #service list
e = 1 # serviсe variable
#Variable value and variable type block
print('==========================================================================================', \
chr(10), 'Variable value and variable type', chr(10))
for c in range(0,5):
print(' Variable',l[0][c], 'of value', l[1][c], 'and type', type(l[1][c]))
print('==========================================================================================', chr(10))
#Sum checking block
print('==========================================================================================', \
chr(10), 'Sum checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Sum checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] + l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot add', l[0][k], 'to', l[0][c])
print(' Result: you cannot add', type(l[1][k]),'to', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can add', l[0][k], 'to', l[0][c])
print(' Answer:', l[1][c] + l[1][k], 'of type', type(l[1][c] + l[1][k]))
print(' Result: you can add', type(l[1][k]), 'to', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Substruction checking block
print('==========================================================================================', \
chr(10), 'Substruction checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Substruction checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] - l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot substruct', l[0][k], 'from', l[0][c])
print(' Result: you cannot substruct', type(l[1][k]),'from', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can substruct', l[0][k], 'from', l[0][c])
print(' Answer:', l[1][c] - l[1][k], 'of type', type(l[1][c] - l[1][k]))
print(' Result: you can substruct', type(l[1][k]), 'from', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Multiplication checking block
print('==========================================================================================', \
chr(10), 'Multiplication checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Multiplication checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] * l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot multiply', l[0][k], 'and', l[0][c])
print(' Result: you cannot multiply', type(l[1][k]),'and', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can multiply', l[0][k], 'and', l[0][c])
print(' Answer:', l[1][c] * l[1][k], 'of type', type(l[1][c] * l[1][k]))
print(' Result: you can multiply', type(l[1][k]), 'and', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Division checking block
print('==========================================================================================', \
chr(10), 'Division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] / l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot divide', l[0][c], 'by', l[0][k])
print(' Result: you cannot divide', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can divide', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] / l[1][k], 'of type', type(l[1][c] / l[1][k]))
print(' Result: you can divide', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Integer division checking block
print('==========================================================================================', \
chr(10), 'Integer division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Integer division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] // l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot integer divide', l[0][c], 'by', l[0][k])
print(' Result: you cannot integer divide', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can integer divide', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] // l[1][k], 'of type', type(l[1][c] // l[1][k]))
print(' Result: you can integer divide', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Taking the remainder from division checking block
print('==========================================================================================', \
chr(10), 'Taking the remainder from division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Taking the remainder from division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] % l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot take the remainder from division', l[0][c], 'by', l[0][k])
print(' Result: you cannot take the remainder from division', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can take the remainder from division', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] * l[1][k], 'of type', type(l[1][c] * l[1][k]))
print(' Result: you can take the remainder from division', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Logical negation checking block
print('==========================================================================================', \
chr(10), 'Logical negation checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Logical negation checking for',type(l[1][c]))
try:
not l[1][c]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot conduct a logical negation of', l[0][c])
print(' Result: you cannot conduct a logical negation of', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can conduct a logical negation of', l[0][c])
print(' Answer:', not l[1][c], 'of type', type(not l[1][c]))
print(' Result: you can conduct a logical negation of', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Algebraic negation checking block
print('==========================================================================================', \
chr(10), 'Algebraic negation checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Algebraic negation checking for',type(l[1][c]))
try:
- l[1][c]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot conduct an algebraic negation of', l[0][c])
print(' Result: you cannot conduct an algebraic negation of', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can conduct an algebraic negation of', l[0][c])
print(' Answer:', - l[1][c], 'of type', type(- l[1][c]))
print(' Result: you can conduct an algebraic negation of', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
print('==========================================================================================')
clear = lambda: os.system('cls')
clear()
val_s = 'Aleksey'
val_i = 5
val_f = 1.2
val_b = 50 < 7
val_nb = not val_b
l = [['val_s ','val_i ','val_f ','val_b ','val_nb'],[val_s,val_i,val_f,val_b,val_nb]] #service list
e = 1 # serviсe variable
#Variable value and variable type block
print('==========================================================================================', \
chr(10), 'Variable value and variable type', chr(10))
for c in range(0,5):
print(' Variable',l[0][c], 'of value', l[1][c], 'and type', type(l[1][c]))
print('==========================================================================================', chr(10))
#Sum checking block
print('==========================================================================================', \
chr(10), 'Sum checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Sum checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] + l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot add', l[0][k], 'to', l[0][c])
print(' Result: you cannot add', type(l[1][k]),'to', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can add', l[0][k], 'to', l[0][c])
print(' Answer:', l[1][c] + l[1][k], 'of type', type(l[1][c] + l[1][k]))
print(' Result: you can add', type(l[1][k]), 'to', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Substruction checking block
print('==========================================================================================', \
chr(10), 'Substruction checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Substruction checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] - l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot substruct', l[0][k], 'from', l[0][c])
print(' Result: you cannot substruct', type(l[1][k]),'from', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can substruct', l[0][k], 'from', l[0][c])
print(' Answer:', l[1][c] - l[1][k], 'of type', type(l[1][c] - l[1][k]))
print(' Result: you can substruct', type(l[1][k]), 'from', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Multiplication checking block
print('==========================================================================================', \
chr(10), 'Multiplication checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Multiplication checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] * l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot multiply', l[0][k], 'and', l[0][c])
print(' Result: you cannot multiply', type(l[1][k]),'and', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can multiply', l[0][k], 'and', l[0][c])
print(' Answer:', l[1][c] * l[1][k], 'of type', type(l[1][c] * l[1][k]))
print(' Result: you can multiply', type(l[1][k]), 'and', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Division checking block
print('==========================================================================================', \
chr(10), 'Division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] / l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot divide', l[0][c], 'by', l[0][k])
print(' Result: you cannot divide', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can divide', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] / l[1][k], 'of type', type(l[1][c] / l[1][k]))
print(' Result: you can divide', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Integer division checking block
print('==========================================================================================', \
chr(10), 'Integer division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Integer division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] // l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot integer divide', l[0][c], 'by', l[0][k])
print(' Result: you cannot integer divide', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can integer divide', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] // l[1][k], 'of type', type(l[1][c] // l[1][k]))
print(' Result: you can integer divide', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Taking the remainder from division checking block
print('==========================================================================================', \
chr(10), 'Taking the remainder from division checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Taking the remainder from division checking for',type(l[1][c]))
for k in range(0,5):
try:
l[1][c] % l[1][k]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot take the remainder from division', l[0][c], 'by', l[0][k])
print(' Result: you cannot take the remainder from division', type(l[1][c]),'by', type(l[1][k]))
e = 1
else:
print(chr(10), ' Operation success: you can take the remainder from division', l[0][c], 'by', l[0][k])
print(' Answer:', l[1][c] * l[1][k], 'of type', type(l[1][c] * l[1][k]))
print(' Result: you can take the remainder from division', type(l[1][c]), 'by', type(l[1][k]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Logical negation checking block
print('==========================================================================================', \
chr(10), 'Logical negation checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Logical negation checking for',type(l[1][c]))
try:
not l[1][c]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot conduct a logical negation of', l[0][c])
print(' Result: you cannot conduct a logical negation of', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can conduct a logical negation of', l[0][c])
print(' Answer:', not l[1][c], 'of type', type(not l[1][c]))
print(' Result: you can conduct a logical negation of', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
#Algebraic negation checking block
print('==========================================================================================', \
chr(10), 'Algebraic negation checking block', chr(10))
for c in range(0,5):
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(' Algebraic negation checking for',type(l[1][c]))
try:
- l[1][c]
except:
e = 0
if e == 0:
print(chr(10), ' Operation error: you cannot conduct an algebraic negation of', l[0][c])
print(' Result: you cannot conduct an algebraic negation of', type(l[1][c]))
e = 1
else:
print(chr(10), ' Operation success: you can conduct an algebraic negation of', l[0][c])
print(' Answer:', - l[1][c], 'of type', type(- l[1][c]))
print(' Result: you can conduct an algebraic negation of', type(l[1][c]))
e = 1
print(' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', chr(10))
e = 1
print('==========================================================================================')
Соседние файлы в папке семестр 1
