Ask Question
27 January, 06:30

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.

+5
Answers (1)
  1. 27 January, 10:25
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers