• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 2. Conditions

Difficulty level:

Task«Bank safety»

You work as a junior developer in an advanced bank that introduces a new automated system to verify financial transactions in real time. The system should be quick and accurate to prevent fraud without creating inconvenience for conscientious customers.

rn

You are instructed to write the key module of this system. The program should analyze the transaction in three parameters: sum, time (hour) and client status (VIP or ordinary). Based on these data, the program makes a verdict: “The transaction is approved” or “The transaction is rejected”.

rn

verification rules:

rn

the transaction is considered permissible and approved if it is performed & nbsp; at least one & nbsp; from the following conditions:

rn rn
  • the transaction amount is strictly less than 10,000 conditional units. In this case, the operation is always approved, regardless of the time and status of the client.
  • rn
  • the client has the status "VIP" and the transaction is made strictly before 18:00.
  • rn
  • the client has the status of "ordinary", the transaction amount is strictly less than 5,000 conditional units, and the transaction is made strictly before 18:00.
  • rn rn

    Your task & mdash; Write a program that requests the amount, time and status for the user, and then displays the solution of the system.

    Input format

    The amount of the transaction (integer)
    the time of the transaction, an hour (an integer is from 0 to 23)
    User status (line, "VIP" or "ordinary")

    Output format

    The system verdict (line, "transaction approved" or "rejected transaction")

    Example

    Input

    15000
    17
    vip

    Output

    The transaction is approved

    Hint

    There will be no clue here, decide for yourself!

    main.py
    Test 1
    Test 2
    Test 3
    Test 4
    Test 5
    Test 6
    Test 7
    Test 8
    Test 9
    Test 10
    Developer’s solution
    # Запрашиваем сумму транзакции и преобразуем введенную строку в целое число
    transaction_amount = int(input())
    
    # Запрашиваем время совершения транзакции (только час) и также преобразуем в целое число
    transaction_time = int(input())
    
    # Запрашиваем статус клиента. Это значение остается строкой ("VIP" или "обычный")
    user_status = input()
    
    # Основное сложное условие для проверки транзакции
    # Оно объединяет все три правила через логический оператор "или" (or)
    # Если хотя бы одна из частей условия верна (True), то весь блок считается верным
    if (transaction_amount < 10000) or \
       (user_status == "VIP" and transaction_time < 18) or \
       (user_status == "обычный" and transaction_amount < 5000 and transaction_time < 18):
        # Если условие выполнено, выводим сообщение об одобрении
        print("Транзакция одобрена")
    else:
        # Если ни одна из частей сложного условия не выполнилась, выводим сообщение об отклонении
        print("Транзакция отклонена")

    🎉 Congratulations! 🎉

    You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

    AD

    Advertisement

    red-snake blue-snake green-snake

    Running your code...

    Помощник ИИ

    Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!