• 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«Financial planning»

you & mdash; Leading financial analyst at the Gemini Capital investment fund. You have received a new project for consideration. Your task & mdash; conduct an express analysis of its financial viability over the past three years and take the verdict: is it worth investing in it.

rn

the main criterion for a positive solution: the project should be profitable & nbsp; each year & nbsp; without exception. This means that the annual income should strictly exceed the annual expense for each of the three analyzed years. If at least in one year the project was unprofitable or worked to zero, it is considered too risky.

rn

Input format

six numbers (as a whole or with a floating point-& nbsp; int & nbsp; or & nbsp; float ), injected consistently, each, each one from the new line.

rn
    rn
  1. income for the 1st year
  2. rn
  3. consumption for the 1st year
  4. rn
  5. income for the 2nd year
  6. rn
  7. consumption for the 2nd year
  8. rn
  9. income for the 3rd year
  10. rn
  11. consumption for the 3rd year
  12. rn

Output format

line ( str ) with the final recommendation.
str ), explaining the reason for the refusal for every unprofitable year.

Example

Input

100000
80000
120,000
95000
150000
110000

Output

The project is recommended for investment.

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
# Запрашиваем у пользователя финансовые показатели за первый год
income_year1 = float(input()) # Принимаем ввод дохода за 1-й год и преобразуем в число
expenses_year1 = float(input()) # Принимаем ввод расхода за 1-й год и преобразуем в число

# Запрашиваем у пользователя финансовые показатели за второй год
income_year2 = float(input()) # Принимаем ввод дохода за 2-й год и преобразуем в число
expenses_year2 = float(input()) # Принимаем ввод расхода за 2-й год и преобразуем в число

# Запрашиваем у пользователя финансовые показатели за третий год
income_year3 = float(input()) # Принимаем ввод дохода за 3-й год и преобразуем в число
expenses_year3 = float(input()) # Принимаем ввод расхода за 3-й год и преобразуем в число

# Проверяем, был ли каждый год прибыльным (доход строго больше расхода)
is_profitable_y1 = income_year1 > expenses_year1
is_profitable_y2 = income_year2 > expenses_year2
is_profitable_y3 = income_year3 > expenses_year3

# Основное условие: если все три года были прибыльными
if is_profitable_y1 and is_profitable_y2 and is_profitable_y3:
    # Если условие истинно, выводим рекомендацию
    print("Проект рекомендуется к инвестированию.")
else:
    # Если хотя бы один год не был прибыльным, выводим отказ
    print("Проект не рекомендуется к инвестированию.")
    
    # Дополнительно проверяем каждый год и сообщаем о проблеме
    if not is_profitable_y1:
        # Если первый год не был прибыльным, указываем это
        print("Причина: Год 1 был убыточным или вышел в ноль.")
    if not is_profitable_y2:
        # Если второй год не был прибыльным, указываем это
        print("Причина: Год 2 был убыточным или вышел в ноль.")
    if not is_profitable_y3:
        # Если третий год не был прибыльным, указываем это
        print("Причина: Год 3 был убыточным или вышел в ноль.")

🎉 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, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!