Вопрос задан 16.06.2023 в 01:03. Предмет Информатика. Спрашивает Суворова Кристина.

Программа запрашивает два числа. Если число положительно, программа вычисляет корень из числа. Если

число отрицательное, программа выводит модуль. Если число равно нулю, выводит числовое сообщение (число равно 0). Помогите с заданием, пожалуйста!!!!
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Сундет Нұрсая.

Ответ:

отметь как лучший ответ. не забудь. Спасибо!

Объяснение:

a=int(input('Введите число:'))

if a>0:

   print(a** (0.5))

elif a<0:

   print(abs(a))

elif a==0:

   print('число равно 0')

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program for Calculating Square Root or Absolute Value

To create a program that requests two numbers and performs different operations based on their sign, you can use conditional statements to check if the number is positive, negative, or zero. Here's a simple example in Python:

```python num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: "))

if num1 > 0: result1 = num1 ** 0.5 # Calculate square root print("Square root of the first number:", result1) elif num1 < 0: result1 = abs(num1) # Calculate absolute value print("Absolute value of the first number:", result1) else: print("The first number is equal to 0")

if num2 > 0: result2 = num2 ** 0.5 # Calculate square root print("Square root of the second number:", result2) elif num2 < 0: result2 = abs(num2) # Calculate absolute value print("Absolute value of the second number:", result2) else: print("The second number is equal to 0") ```

This program prompts the user for two numbers, checks their signs, and then calculates the square root if the number is positive, the absolute value if it's negative, or prints a message if it's zero.

Example Output: ``` Enter the first number: 9 Enter the second number: -4 Square root of the first number: 3.0 Absolute value of the second number: 4.0 ```

This code snippet demonstrates a simple way to achieve the desired functionality.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос