Ask Question
16 November, 18:56

Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calculate and then print the result when int1 is raised to the int2 power. You also want to calculate the result when int1 is raised to the. 5 power; however, you realize that it is not possible to take the square root of a negative number. If the value for int1 that is entered is a negative number, print a message to the user explaining why you cannot complete the task. Otherwise, calculate the square root and print it. Finish the program by printing the values of int1 and int2.

+2
Answers (1)
  1. 16 November, 21:27
    0
    int1=int (input ("Enter integer : /n")) #taking input of first number.

    int2=float (input ("Enter the power : /n")) #taking input of the power.

    if int2 = = 0.5 and int1<0:#condition for negative square root.

    print ("Cannot calculate the square root of negative numbers") #printing the message.

    else:#else calculating the result.

    res=int1**int2

    print (res)

    output:-

    Enter integer:

    -5

    Enter the power:

    0.5

    Cannot calculate the square root of negative numbers

    Explanation:

    In the above program I have taken input of the number and the power. Since power can be decimal number taking it as float. If the number is negative and the power is 0.5 then printing the message for not calculating the value else calculating the value and storing it in the res printing the res.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calculate and ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers