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
krok68 [10]
2 years ago
10

Problem: Write the Python code of a program called ComputeSquare that asks the user to enter the length of the side of the squar

e and displays the area and perimeter of the square. Check that the side length is greater than zero, and if it is not, display an informative error message to the user. ​
Computers and Technology
1 answer:
Lera25 [3.4K]2 years ago
6 0
<h2>Solution :</h2>

The given problem is solved in Python.

def ComputeSquare():

side = float(input('Enter the side of the square: '))

if side > 0:

perimeter = 4 * side

area = side * side

print('Perimeter of the square is:',

perimeter, 'unit.')

print('Area of the square is:', area, 'square unit.')

<h3> else:</h3>

print('Invalid input.')

ComputeSquare()

<h2>Explanation :-</h2>

  • In this program, we create a function ComputeSquare() to calculate the perimeter and area of a square.

  • The function asks the user to enter the side of the square. The side is then stored in a variable.

  • Now, we check whether the side is greater than 0 or not using if-else statement.

  • If the condition is true, the perimeter and area is calculated which is displayed using print() statement.

  • If the condition is false, the else blocks executes printing the error message.

<h3>Refer to the attachment for output.</h3>

You might be interested in
I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
liq [111]
The number of bullet points on a slide should not exceed till 8
3 0
3 years ago
Tor F: Deleting cell data is the same as clearing the contents of a cell.
Valentin [98]

Answer:

no it is not

Explanation:

it's not because of the cells in side the chip for the data that comes from the cell phone

4 0
3 years ago
Your hometown probably has little to offer in terms of photography because you've already seen it. True False
Nikitich [7]
False it the answer bro
4 0
3 years ago
What does the term hardware refer to?
Jobisdone [24]

Answer:

The physical components that a computer is made of

Explanation:

as u can see these components and u can repaire these components if they got damaged

6 0
3 years ago
A __________ is the blueprint for __________ having similar attributes and behaviors. signature, objects class, parameters heade
MrRa [10]

Answer: E. class, objects

Explanation:

<em>A </em><em><u>class</u></em><em> is the blueprint for </em><em><u>objects</u></em><em> having similar attributes.</em>

As much as classifying something means to define it based on the characteristics that is has that are similar to other things in that class, so also is a class here.

A class is the blueprint or rather template for making objects that have similar attributes which means that the class therefore gives the object its various attributes and its behavior.

4 0
2 years ago
Other questions:
  • You run an automobile selling company that has a popular online store on AWS. The application sits behind an Auto Scaling group
    6·1 answer
  • Which encryption standard goes with the WPA2 protocol?<br> AES<br> DES<br> TKIP<br> WPS
    10·1 answer
  • Consider the following threats to Web security, and describe how each is countered by a particular feature of SSL.
    15·1 answer
  • State all the generations of computers.
    10·2 answers
  • 5. How would you describe the relationship between blocks of code and commands?​
    14·2 answers
  • I prefer a job where I am praise for good performance or I am accountable for results
    13·1 answer
  • To open a Google Doc in another software application, the user must first download it. True or false?
    12·2 answers
  • In a _error,solution is working but not giving required results
    14·1 answer
  • What are some common uses of Excel?
    10·1 answer
  • Extended essay on globalization not less than 200​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!