Объяснение:
program XandY;
const
rndlim=50;
var
x, y : integer;
begin
x:=random(rndlim);
y:=random(rndlim);
Writeln('x=',x,' y=', y);
Writeln('x+y = ',x+y);
Writeln('x-y = ',x-y);
Writeln('x*y = ',x*y);
Writeln('x^2 + y^2 = ',sqr(x)+sqr(y));
end.
Запуск:
Free Pascal Compiler version 2.6.2-8 [2014/01/22] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling main.pas
Linking a.out
16 lines compiled, 0.2 sec
x=27 y=29
x+y = 56
x-y = -2
x*y = 783
x^2 + y^2 = 1570
def rate_f(movies):
if len(dictionary[movies]) == 0:
return True
def film_in_dictionary(movies):
if movies in dictionary:
else:
return False
def average(movies):
mean = 0
for key2 in dictionary[movies].keys():
mean += dictionary[movies][key2]
print(f'{movies} средняя оценка: {mean / len(dictionary[movies])}')
dictionary = {}
while True:
command = input('Введите команду: ')
if command != 'exit' and command != 'list' and command != 'add' and command != \
'delete' and command != 'rate' and command != 'find':
print('Error')
continue
if command == 'exit':
break
if command == 'list':
for key in dictionary.keys():
if rate_f(key):
print(f'{key} не оценивался')
average(key)
film = input('Введите название фильма: ')
if command == 'add':
if film_in_dictionary(film):
dictionary[film] = {}
elif command == 'delete':
if film in dictionary:
del dictionary[film]
elif command == 'rate':
name = input('Имя пользователя: ')
rate = float(input('Оценка: '))
if 0 < rate <= 10:
dictionary[film][name] = rate
elif command == 'find':
if rate_f(film):
for name, rate in dictionary[film].items():
print(f'{name} поставил оценку: {rate}')
average(film)
Объяснение:
program XandY;
const
rndlim=50;
var
x, y : integer;
begin
x:=random(rndlim);
y:=random(rndlim);
Writeln('x=',x,' y=', y);
Writeln('x+y = ',x+y);
Writeln('x-y = ',x-y);
Writeln('x*y = ',x*y);
Writeln('x^2 + y^2 = ',sqr(x)+sqr(y));
end.
Запуск:
Free Pascal Compiler version 2.6.2-8 [2014/01/22] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling main.pas
Linking a.out
16 lines compiled, 0.2 sec
x=27 y=29
x+y = 56
x-y = -2
x*y = 783
x^2 + y^2 = 1570
def rate_f(movies):
if len(dictionary[movies]) == 0:
return True
def film_in_dictionary(movies):
if movies in dictionary:
return True
else:
return False
def average(movies):
mean = 0
for key2 in dictionary[movies].keys():
mean += dictionary[movies][key2]
print(f'{movies} средняя оценка: {mean / len(dictionary[movies])}')
dictionary = {}
while True:
command = input('Введите команду: ')
if command != 'exit' and command != 'list' and command != 'add' and command != \
'delete' and command != 'rate' and command != 'find':
print('Error')
continue
if command == 'exit':
break
if command == 'list':
for key in dictionary.keys():
if rate_f(key):
print(f'{key} не оценивался')
else:
average(key)
continue
film = input('Введите название фильма: ')
if command == 'add':
if film_in_dictionary(film):
print('Error')
else:
dictionary[film] = {}
elif command == 'delete':
if film in dictionary:
del dictionary[film]
else:
print('Error')
elif command == 'rate':
name = input('Имя пользователя: ')
rate = float(input('Оценка: '))
if 0 < rate <= 10:
dictionary[film][name] = rate
else:
print('Error')
elif command == 'find':
if rate_f(film):
continue
for name, rate in dictionary[film].items():
print(f'{name} поставил оценку: {rate}')
average(film)