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
The conventional wisdom concerning the security frameworks of domains is that it is always preferable for an organization to cre
Valentin [98]

Answer:

False

Explanation:

A Domain Based Security. "Domain Based Security", abbreviated to "DBSy", is a model-based approach that is being used in analyzing information security risks in a business context and offers an apparent, understandable and direct mapping among the risks and the security controls needed to handle them.

While A security domain is the list of items a subject is permitted to access. More largely defined, domains are collections of subjects and objects with related security requirements.

6 0
3 years ago
Which slide elements must claire use to enhance her presentation?
Crank

The answer for the 1st blank is text.


6 0
3 years ago
Read 2 more answers
PLEASE HELP THIS WAS DUE YESTERDAY AND I DIDN'T GET TO IT IN TIME!!!!!!
kykrilka [37]

Answer:

dDAgv

Explanation:

sdc sdc sdc trust me

7 0
3 years ago
Instructions:Type the correct answer in the box. Spell all words correctly.
weeeeeb [17]
The answer should be RAM = Random Access Memory

RAM memory is used to store current data while the computer is on. Bear in mind that after the computer is shutdown all data in RAM is lost.
6 0
3 years ago
Read 2 more answers
Technician A says that volatility describes how hard it is for gasoline to evaporate. Technician B says that Reid vapor pressure
Lubov Fominskaja [6]

I’d say both techies are correct.

Volatility, as applied in gasoline, is quantified by the tendency of the liquid to change to vapor at any given temperature (vaporize). This rate of change might be hard or easy, this depends on the temperature or the pressure. Technician B is also correct. RVP is defined and determined experimentally according to the ratio of the vapor volume to the liquid volume at 100 °F.

8 0
3 years ago
Other questions:
  • Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
    9·1 answer
  • Which of the following describe a required
    7·1 answer
  • What is an IP address and where I can find the IP address for my computer?
    14·1 answer
  • All of the following are advantages of database-stored information, except ______________. Multiple Choice
    7·1 answer
  • Assembly (Procedure and Conditional Processing). For the following program, what are outputs for register EAX, EBX, ECX, and EDX
    11·1 answer
  • Write an algorithm to display your name 10 times​
    5·1 answer
  • Which three pieces of information should be included in an artist statement? Select all that apply.
    11·1 answer
  • If a password is entered wrongly three times the computer will
    15·1 answer
  • Which item can be added to Outlook messages, like a Word document or PowerPoint presentation, that takes standard bulleted lists
    11·1 answer
  • to troubleshoot an output component or input device, the first step is to activate the input device that controls the first outp
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!