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
In today's digital marketplace, the line between retailer and distributor has become less distinct.
jenyasd209 [6]

Answer:

The answer you're looking for is True - The line between retailer and distributor has become less distinct.

Explanation:

5 0
3 years ago
Which of the following is not a valid FICO Credit score?
kumpel [21]

Answer: C 475

Explanation:  These choices are A. 375, B. 276, and D. 575. so that wolde mean it would be C 475.

8 0
3 years ago
Read 2 more answers
_____ regulate current/voltage flow, similar function as _____,but are smaller, cheaper, and more reliable.
Tpy6a [65]

Direct Current Power regulates current/voltage flow, similar function as unregulated or regulated, but is smaller, cheaper, and more reliable.

<h3>What is Direct Current Power?</h3>
  • In contrast to the flow of a river, direct current is a technique in which electricity constantly flows in the same direction. It speaks about the flow of electricity produced by batteries, solar cells, and other sources.
  • Alternating current (AC), on the other hand, is a technique in which the positive and negative sides are consistently swapped at regular intervals, changing the direction of the electricity flow in accordance.
  • This is the electricity that comes from a generator or a plug-in.
  • Alternating current is used to transmit both the electricity generated at power plants and the electricity delivered to houses.

To learn more about Direct Current Power, refer:

brainly.com/question/1402412

#SPJ4

8 0
2 years ago
What is the best website to get a iphone
sveticcg [70]
Generally I'd recommend not buying one online, tends to be cheaper from a shop - and better used, although their are some risks with 2nd hand devices, I think the big price cut it worth it. 

If you did want to buy online, maybe Amazon or Ebay?
7 0
3 years ago
Read 2 more answers
You have been tasked with finding the routers that have been installed between two networks. what utility would you use to provi
Kazeer [188]
Netstat -r

Should take care of it.
4 0
3 years ago
Other questions:
  • Consider the following scenario: "You are an assistant to the accounting manager for a small company that sells sports equipment
    5·1 answer
  • Technician A says that wheel speed sensors are a highly probable cause of illuminated EBC warning lamps. Technician B says that
    10·1 answer
  • Select four programs that make up system software.Select four programs that make up system software.
    8·1 answer
  • Write a function stats that takes an array and the number of elements in the array. Then, it computes and prints the minimum val
    8·1 answer
  • //Display message Module main () // Declare variables Declare real weight Declare real shipping //Get package weight Call getWei
    7·1 answer
  • Given an array arr, of type int, along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j
    11·1 answer
  • Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither.
    5·1 answer
  • The find_item functions uses binary search to recursively locate an item is the list, returning true if found, false otherwise.
    13·1 answer
  • Heya!!<br><br>•DEFINE DATA SCIENCE??<br>(∩_∩)<br><br>#kavya#<br>​
    6·1 answer
  • HELP 100 points
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!