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
Degger [83]
3 years ago
9

including how it can be stored and what types of operations we can perform. For example, we can write a program that squares num

bers, but it wouldn’t be able to square a word.
Computers and Technology
1 answer:
ASHA 777 [7]3 years ago
6 0

Answer:

The solution code is written in Python:

  1. def square(num):
  2.    if type(num).__name__ == 'int':
  3.        sq_num = num * num
  4.        return sq_num  
  5.    else:
  6.        return "Invalid input"
  7. print(square(5))
  8. print(square("Test"))

Explanation:

To ensure only certain type of operation can be applied on a input value, we can check the data type of the input value. For example, we define a function and name it as <em>square</em> which take one input number, <em>num </em>(Line 1).

Before the <em>num</em> can be squared, it goes through a validation mechanism in by setting an if condition (Line 2) to check if the data type of the input number is an integer,<em> int.</em> If so, the<em> num </em>will only be squared otherwise it return an error message (Line 6).

We can test our function by passing value of 5 and "Test" string. We will get program output:

25

Invalid input

You might be interested in
Trong ửod muốn trình bày dạng cột càn thực hiện lệnh nào
velikii [3]

Answer:

Tác dụng của phím tắt trong Word thì đã quá rõ ràng rồi, nó giúp bạn soạn thảo văn bản, căn chỉnh lề, kích thước, cắt, dán…. nhanh hơn rất nhiều, bạn càng nhớ nhiều phím tắt bao nhiêu thì càng tiện lợi bấy nhiêu.

Explanation:

3 0
2 years ago
Instead of terminating the series, the producers decided to extend it for an additional season. In the sentence above, which of
Leya [2.2K]
I believe it would be "Use the context to find a synonym for terminating." (Also next time try posting in the English section :) )
6 0
3 years ago
Convert one billion byte into one storage unit​
notka56 [123]

Answer:

Explanation:

To convert larger units to smaller units (i.e. take a number of gigabytes and convert it down in to megabytes, kilobytes, or bytes) you simply multiply the original number by 1,024 for each unit size along the way to the final desired unit

7 0
3 years ago
When malicious code is planted on your computer and alters your browser's ability to find web addresses, it is known as ________
tresset_1 [31]
The answer is Phishing
3 0
3 years ago
Read 2 more answers
I dunno what to write my memo thing about ⁻³⁻
Alex73 [517]

Answer:

Wdym? I could help u

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    15·1 answer
  • Spreadsheet software creates a ____, composed of a grid of columns and rows
    6·1 answer
  • A popular database software program called ____ offers a wizard and QBE tool to help build and generate SQL queries
    9·1 answer
  • Android OS "AFTER" Alpha.<br><br> A. Bubblegum<br><br> B. Beta<br><br> C. Berry<br><br> D. Buzz Cola
    10·1 answer
  • Write an application that allows a user to input the height and width of a rectangle. It should output the area and perimeter of
    10·1 answer
  • Create a basic program that accomplishes the following requirements: Allows the user to input 2 number , a starting number x and
    12·1 answer
  • If, after fetching a value from memory, we discover that the system has returned only half of the bits that we expected; it is l
    8·1 answer
  • The higher the ____________________, the faster the ____________________.
    5·1 answer
  • Select the three concepts of capital outlay.
    15·1 answer
  • A leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate h
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!