class ATM:
def __init__(self):
self.money = 0.0
self.password = '1234'
def add_money(self, _money) -> bool:
if float(_money) > 0.0:
self.money += float(_money)
return True
return False
def pass_check(self) -> bool:
tries = 1
while input('Give me the password:\n> ') != self.password:
if tries > 2:
return False
tries+=1
print(f'#{tries}: Bad password')
return True
def withdraw(self, _money) -> bool:
if not self.pass_check():
self.close_session()
return False
if float(_money) > 0.0 and self.money - float(_money) >= 0.0:
self.money -= float(_money)
return True
return False
def get_balance(self) -> float:
return self.money
def close_session(self) -> None:
raise SystemExit(0)
# Пример использования 1
_atm = ATM()
_atm.add_money(1700)
print('Your balance is ' + str(_atm.get_balance()))
_atm.withdraw(1600)
print('Your balance is ' + str(_atm.get_balance()))
# Пример использования 2
_atm = ATM()
if _atm.add_money(1600):
print('Money successfully added!')
else:
print('Error while money adding.')
print('Your balance is ' + str(_atm.get_balance()))
if _atm.withdraw(1700):
print('Successfully withdrawn!')
else:
print('Error while money withdrawing.')
C# 8.0:
using System;
using System.Collections.Generic;
...
Random rnd = new Random();
long SumOfGreater50 = 0, Mult3 = 0, Num, n = 10;
var Negative = new List<long>();
for (; n > 0; n--)
{
Num = rnd.Next(-100, 101);
if (Num % 3 == 0)
Mult3++;
if (Num > 50)
SumOfGreater50 += Num;
if (Num < 0)
Negative.Add(Num);
}
Console.WriteLine($"Num of multipliers of 3: {Mult3}");
Console.WriteLine("Negative nums:");
foreach (long i in Negative) Console.Write($"{i} ");
Console.WriteLine($"\nSum of nums greater than 50:{SumOfGreater50}");
По горизонтали:
1. Как называется операция, которая резервирует в памяти место под элементы массива? 4. Массив, который состоит только из чисел. 6. Группа символов, указывающих на конкретный массив. 8. Величина, указывающая на расположение элементов в массиве. 9. В массиве все элементы одного … 10. Множество элементов одного типа и одного имени.
По вертикали:
1. Название массива, в котором все элементы расположены в одну строку или один столбец. 2. Что указывает на положение элемента в массиве? 3. Расположение элементов в определенном порядке. 5. Величина, которая указывает количество элементов в массиве. 7. Другое название двумерного массива.