Skip to content

Условный оператор и тип данных bool #1

@MaxZarev

Description

@MaxZarev
# задание 1
balance = int(input('Введите баланс: '))
if 0 > balance:
    print('нищий')
elif 1 < balance < 100:
    print('деген')
elif 100 < balance < 1000:
    print('кит')
elif 1000 < balance:
    print('Илон Маск')
else:
    int(input('Введите баланс еще раз: '))
 

# задание 2

import random
gas_price = random.randint(10,100)
wallet_balance = random.randint(2000,10000)

scroll_bridge_cost = gas_price * 75
scroll_swap_cost = gas_price * 40
clusters_mint_cost = gas_price * 100
min_balance = scroll_swap_cost + scroll_bridge_cost + clusters_mint_cost

#флаги
withdraw_flag = False
bridge_performed = False
swap_performed = False
mint_performed = False

#информация по переменным
print(f'Цена газа - {gas_price}, баланс кошелька - {wallet_balance}')
print(f'Бридж - {scroll_bridge_cost}, Своп - {scroll_swap_cost} , Минт домена - {clusters_mint_cost}')
print(f'Минимальный баланс для запуска - {min_balance}')

#проверка возможности запуска
if wallet_balance < min_balance and gas_price < 50:
    withdraw = min_balance - wallet_balance
    print(f'Баланса не хватает, вывожу с биржи {withdraw}')
    wallet_balance += withdraw
    print(f'Новый баланс - {wallet_balance}')
    withdraw_flag = True

#выполнение программы в зависимости от газа
if gas_price < 25:
    print(f'Запускаю мост Скрол')
    wallet_balance -= scroll_bridge_cost
    bridge_performed = True
    if gas_price < 15:
        print(f'Делаю минт домена')
        wallet_balance -= clusters_mint_cost
        mint_performed = True
elif 25 < gas_price < 50:
    print(f'Делаю свап')
    wallet_balance -= scroll_swap_cost
    swap_performed = True
else:
    print(f'Рекомендую подождать низкого газа')

#Отчет

print(f'Работа завершена. Отчет:')
if withdraw_flag:
    print('Сделан вывод с биржи')
if bridge_performed:
    print(f'Выполнен мост Скрол')
if swap_performed:
    print(f'Выполнен свап')
if mint_performed:
    print(f'Выполнен минт домена')
if not withdraw_flag and not bridge_performed and not swap_performed and not mint_performed:
    print(f'Ничего не выполнено, ждем низкий газ')
print(f'Остаточный баланс Кошелька - {wallet_balance}')
# задание 3

import random
import time

balance_eth = random.uniform(0.005, 0.2)
balance_usdc = random.randint(200, 1000)
eth_price = random.randint(3100,3500)

print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}, Курс ETH - {eth_price}')

if balance_usdc:
    eth_received = balance_usdc /eth_price
    print(f'Обмен всех токенов {balance_usdc} USDC в {eth_received} ETH')
    balance_usdc = 0
    balance_eth += eth_received
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')
else:
    eth_to_swap = balance_eth * 0.95
    usdc_recived = eth_to_swap * eth_price
    print(f'Обмениваю {eth_to_swap} ETH на {usdc_recived} USDC')
    balance_eth *= 0.05
    balance_usdc += usdc_recived
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')

print(f'Выполнен обмен 1')

time.sleep(random.randint(3,15))

if balance_usdc:
    eth_received = balance_usdc /eth_price
    print(f'Обмен всех токенов {balance_usdc} USDC в {eth_received} ETH')
    balance_usdc = 0
    balance_eth += eth_received
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')
else:
    eth_to_swap = balance_eth * 0.95
    usdc_recived = eth_to_swap * eth_price
    print(f'Обмениваю {eth_to_swap} ETH на {usdc_recived} USDC')
    balance_eth *= 0.05
    balance_usdc += usdc_recived
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')

print(f'Выполнен обмен 2')

time.sleep(random.randint(3,15))

if balance_usdc:
    eth_received = balance_usdc /eth_price
    print(f'Обмен всех токенов {balance_usdc} USDC в {eth_received} ETH')
    balance_usdc = 0
    balance_eth += eth_received
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')
else:
    eth_to_swap = balance_eth * 0.95
    usdc_recived = eth_to_swap * eth_price
    print(f'Обмениваю {eth_to_swap} ETH на {usdc_recived} USDC')
    balance_eth *= 0.05
    balance_usdc += usdc_recived
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')

print(f'Выполнен обмен 3')

time.sleep(random.randint(3,15))

if balance_usdc:
    eth_received = balance_usdc /eth_price
    print(f'Обмен всех токенов {balance_usdc} USDC в {eth_received} ETH')
    balance_usdc = 0
    balance_eth += eth_received
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')
else:
    eth_to_swap = balance_eth * 0.95
    usdc_recived = eth_to_swap * eth_price
    print(f'Обмениваю {eth_to_swap} ETH на {usdc_recived} USDC')
    balance_eth *= 0.05
    balance_usdc += usdc_recived
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')

print(f'Выполнен обмен 4')

time.sleep(random.randint(3,15))

if balance_usdc:
    eth_received = balance_usdc /eth_price
    print(f'Обмен всех токенов {balance_usdc} USDC в {eth_received} ETH')
    balance_usdc = 0
    balance_eth += eth_received
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')
else:
    eth_to_swap = balance_eth * 0.95
    usdc_recived = eth_to_swap * eth_price
    print(f'Обмениваю {eth_to_swap} ETH на {usdc_recived} USDC')
    balance_eth *= 0.05
    balance_usdc += usdc_recived
    print(f'Баланс ETH - {balance_eth}, Баланс USDC - {balance_usdc}')

print(f'Выполнен обмен 5')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions