1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LekaFEV [45]
3 years ago
6

Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calcu

late 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.
Computers and Technology
1 answer:
Triss [41]3 years ago
4 0

Answer:

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.

You might be interested in
A computer system has 9,850 processes and 172 of them were suspended while 276 of them were terminated. Explain why some of the
Mrrafil [7]

Answer:

Check below for answers and explanations.

Explanation:

The major reasons why computer processes are suspended or terminated are:

1. When there is insufficient memory for successful completion of the process

2. When there's an unauthorized access of any of the computer resources by the process.

It is possible that some processes are terminated why some are suspended because, when the system runs out of memory, the running processes are put on hold until the system is able to create free memory space for the completion of the process. In this case the process is suspended. But if the system cannot provide enough space for the process, the process is terminated.

In the example provided in this exercise, some of the processes were suspended because the system wants to create free memory space for their completion while others are terminated either because the available space is not sufficient for their completion or they want to access an unauthorized resources on the system.

4 0
2 years ago
Suppose that the splits at every level of quicksort are in the proportion 1 − α to α where 0 &lt; α ≤ 1/2 is a constant. Show th
Lady_Fox [76]

Answer:

Explanation:

The minimum depth occurs for the path that always takes the smaller portion of the

split, i.e., the nodes that takes α proportion of work from the parent node. The first

node in the path(after the root) gets α proportion of the work(the size of data

processed by this node is αn), the second one get (2)

so on. The recursion bottoms

out when the size of data becomes 1. Assume the recursion ends at level h, we have

(ℎ) = 1

h = log 1/ = lg(1/)/ lg = − lg / lg

Maximum depth m is similar with minimum depth

(1 − )() = 1

m = log1− 1/ = lg(1/)/ lg(1 − ) = − lg / lg(1 − )

4 0
3 years ago
We informally define the term corresponding element as follows: The first element in an array and the last element of the array
yanalaym [24]

The corresponding element in an array can be written as follows.

The given array is arr[len] whose size is given by integer variable len. We take another integer variable k.

Corresponding element for arr[k] = arr[len-1-k]

This applies for all expressions of k beginning from 0 upto half the size of len, i.e., len/2.

For element, arr[0], the corresponding element is arr[10-1-0] = arr[9].

The above expression is valid if the sum of index of both element and its corresponding element adds upto the index of the last element of the array.

Example: k + (len – 1 - k)  

= k + len – 1 - k

= len – 1

= index of the last element of the array

The number of elements that an array can hold is one more than the index of the last element of the array.

Suppose an array of 10 elements is given. The above expression holds true since first element of the array is always written as arr[0] and last element will be written as arr[9] for an array of 10 elements.

This is illustrated below.

The c++ program to display the element and its corresponding element along with their index is shown below.

#include <iostream>

using namespace std;

int main() {    

   int len=10, arr[len],k;    

   for(k=0; k<len; k++)

   {

       // elements are initialized to twice their index

       arr[k] = k*2;

   }

   cout<<"Element "<<" Index "<<"\t"<<" Corresponding "<<" Index"<<endl;

   for(k=0; k<len/2; k++)

   {

       cout<<arr[k]<<"\t"<<"\t"<<"\t"<<k<<"\t"<<"\t"<<"\t"<<arr[len-1-k]<<"\t"<<"\t"<<len-1-k<<endl;

   }

}

OUTPUT

Element Index    Corresponding   Index

0  0   18  9

2  1   16  8

4  2   14  7

6  3   12  6

8  4   10  5

 

The above program initializes all the elements of the array to twice the value of their corresponding index. Following this, the element, its index, the corresponding element and its index is displayed.

All the above is achieved using for loop. The size of the array and its elements can be changed.

The expression for the corresponding element is thus explained.

7 0
2 years ago
In a category of games known as _________, millions of players connect to various servers to team up with other players in very
aivan3 [116]

In a category of games known as MMORPGs, millions of players connect to various servers to team up with other players in very large virtual worlds.

<h3>What do MMORPGs mean?</h3>

The term  MMORPG connote  massively multiplayer online role-playing games.

This is known to be a type of video game that tends to make use of different elements of role-playing games (RPGs) along with those of the gameplay of multiplayer online gaming worlds.

Therefore, In a category of games known as MMORPGs, millions of players connect to various servers to team up with other players in very large virtual worlds.

Learn more about virtual worlds from

brainly.com/question/13873769

#SPJ1

3 0
1 year ago
What are the advantages and disadvantages of using a very large memory cell size, say, W = 64 instead of the standard size W = 8
stepladder [879]

Answer and Explanation:

  • The benefits of an large size memory cell is that you can store a lot bigger numbers (and all information is, eventually, numbers) in one cell, which by and large improves the speed and unwavering quality of information get to.  
  • The inconvenience is that you go through a bigger bit of whatever information stockpiling medium you are utilizing on each expression of information, and accordingly can store less information generally speaking.  
  • The biggest positive integer that could be put away in a framework utilizing sign/size documentation, with 64-piece cells is 263. On the off chance that two such cells were utilized to store numbers, the biggest whole number that could be put away by the framework is 2127.
7 0
2 years ago
Other questions:
  • Computer design replaced ______________
    14·1 answer
  • ​User documentation _____. Group of answer choices ​allows users to prepare overall documentation, such as process descriptions
    9·1 answer
  • Pseudoscience is
    5·2 answers
  • Typing with capital letters and exclamation points in an e-mail is an example of
    12·2 answers
  • 1) Using the density equation d=m/V: What is the density of a piece of metal with a mass o
    10·1 answer
  • Write a program that prompts the user to enter an oligonucleotide sequence, such as TATGAGCCCGTA.
    7·1 answer
  • Which type(s) of license(s) allow the underlying software code to be viewed?
    15·1 answer
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
  • An early attempt to force users to use less predictable passwords involved computer-supplied passwords. The passwords were eight
    10·1 answer
  • What is Converting digital data and see information to display screen can use to create an image?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!