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
Digiron [165]
3 years ago
12

Write a pyhton program to calculate area of a circle?

Computers and Technology
1 answer:
marta [7]3 years ago
8 0

Answer:

The code to calculate the area of a circle is:

from math import pi

def circleArea(radius):

 if radius > 0:

   return pi * (radius ** 2)

 else:

   return None

if __name__ == '__main__':

 radius = 5

 print("Radius: {} Area: {}".format(radius,circleArea(radius)))

Explanation:

A detailed explanation of each line of code is given below.

#Define the number pi used to calculate the area

from math import pi

#We define a function that calculates the area of a circle

def circleArea(radius):

#Check if the radius is valid ( radius > 0) since there aren´t negative radius

 if radius > 0:

#Compute the area formula for a circle \pi * radius^{2}

   return pi * (radius ** 2)

 else:

#Return None if the radius is invalid

   return None

#Run the function we´ve defined

if __name__ == '__main__':

#Define a radius

 radius = 5

#Call the function and parse the radius through it, then print the result

 print("Radius: {} Area: {}".format(radius,circleArea(radius)))

You might be interested in
What paper should I use for technical drawing?
Vitek1552 [10]

Answer:

classic A4 format, and therefore for 210 x 297 mm sheets

7 0
3 years ago
The power ratio 1.774 is equivalent to how many dB?
kvv77 [185]

Answer:

2.489 dB

Solution:

As per the question:

Power ratio, \frac{P'}{P} = 1.774

The Equivalent of this power ratio in decibel or dB is calculated by taking the log of the power ratio as below:

\frac{P'}{P}_{dB} = 10log_{10}\frac{P'}{P}

\frac{P'}{P}_{dB} = 10log_{10}\times 1.774 = 10\times 0.2489 = 2.489 dB

Thus the value of the power ration in decibel comes out to be 2.489 dB

3 0
3 years ago
Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo
dolphi86 [110]

Answer:

The function in C++ is as follows

int chkInd(string str1, string str2){    

int lenstr1=0;

while(str1[lenstr1] != '\0'){  lenstr1++;  }

int index = 0; int retIndex=0;

for(int i=lenstr1-1;i>=0; i--){

   while (str2[index] != '\0'){

       if (str1[i] == str2[index]){

           retIndex=1;

           break;         }

       else{   retIndex=0;      }

  index++;    }

  if (retIndex == 0){   return i;   }else{return -1;}}

}

Explanation:

This defines the function

int chkInd(string str1, string str2){    

First, the length of str1 is initialized to 0

int lenstr1=0;

The following loop then calculates the length of str1

while(str1[lenstr1] != '\0'){  lenstr1++;  }

This initializes the current index and the returned index to 0

int index = 0; int retIndex=0;

This iterates through str1

for(int i=lenstr1-1;i>=0; i--){

This loop is repeated while there are characters in str2

   while (str2[index] != '\0'){

If current element of str2 and str1 are the same

       if (str1[i] == str2[index]){

Set the returned index to 1

           retIndex=1;

Then exit the loop

           break;         }

If otherwise, set the returned index to 0

       else{   retIndex=0;      }

Increase index by 1

  index++;    }

This returns the calculated returned index; if no matching is found, it returns -1

  if (retIndex == 0){   return i;   }else{return -1;}}

}

4 0
3 years ago
_____ emphasizes identifying and monitoring the sources of new technologies for an industry. Licensing Differentiation Environme
nalin [4]
Mass is the answer if u need me ask me ok

8 0
3 years ago
A stored program computer is designed to compute precisely one computation, such as a square root, or the trajectory of a missil
mr Goodwill [35]

Answer: False

Explanation:

 The given statement is false as, a stored program computer is one of the type of computer system which storing the program instruction in the form of electronic memory.

  • It perform different types of tasks in the sequence and it also enables the digital computer system more effective and flexible.
  • In this stored program computer the program instructions are get stored on the plugboards.

Therefore, the given statement is false.

4 0
3 years ago
Other questions:
  • Which of the following statements is false? a. Each object of a class shares one copy of the class's instance variables. b. A cl
    11·1 answer
  • Can someone please help??
    12·1 answer
  • The picture that graphically represents the items you use in windows is called a/an
    5·1 answer
  • What's the name of this apex legend hero​
    13·2 answers
  • How to study program ?
    11·1 answer
  • Find two consecutive even integers such that twice the smaller is 16 more than the larger
    10·1 answer
  • Don is visiting digital stores and searching the internet to learn about high-definition DVD players before he buys one. This is
    8·1 answer
  • How does computer applications affect our lives daily? 1- paragraph (4 sentences)
    8·2 answers
  • What is the purpose of the Zoom dialog box? to put the selected range in ascending order in a query to put the selected range in
    13·2 answers
  • You can put ______ on your phone.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!