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
Which of the following statements is correct?
vaieri [72.5K]

Answer:

A

Explanation:

I think is A. or maybe search up the topic of the lesson

7 0
3 years ago
Select the true statement about the motherboard.
Nata [24]

Answer:

it executes the commands sent to it by the applica software .

8 0
2 years ago
Questions: What memory modules are needed if the customer wants 3 GB of RAM? What capacities and how many modules of each capaci
zhannawk [14.2K]

Answer:

You could use three 1 GB modules.

4 0
2 years ago
How does a barcode work?
Genrish500 [490]
A barcode's bars have 

1. different thicknesses, so they each signify 1 or 2 nibbles. 
2. the combinations of the thicknesses of those bars exceed the trillions. That's why manufacturers and stores never run out of SKU barcodes.
4 0
3 years ago
Create a program in Matlab that prints the numbers from 1-100.
Burka [1]

Answer:

numbers = 1:1:100;

for num=numbers

remainder3 = rem(num,3);

remainder5 = rem(num,5);

 

if remainder3==0

disp("Yee")

else

if remainder3 == 0 && remainder5 == 0

disp ("Yee-Haw")

else

if remainder5==0

disp("Haw")

else

disp("Not a multiple of 5 or 4")

end

end

end  

end

Explanation:

  • Initialize the numbers variable from 1 to 100.
  • Loop through the all the numbers and find their remainders.
  • Check if a number is multiple of 5, 3 or both and display the message accordingly.
4 0
3 years ago
Other questions:
  • What is the difference between a switch's physical interface and the vlan interface?
    10·2 answers
  • 9. The best way to insert an existing Excel chart into a document is to A. use the Object command. B. click the Insert tab and c
    6·2 answers
  • Write a memo to the vice president, outlining the steps an employee might have taken to create an e-mail message and make it app
    15·1 answer
  • (I'm sorry that this question isn't school related, I can't find answers anywhere else)
    8·1 answer
  • Using the C language, write a function that accepts two parameters: a string of characters and a single character. The function
    11·1 answer
  • You should structure the<br> first before you search for a relevant picture.
    11·1 answer
  • select all examples of proper keyboarding technique. rest your fingers gently on the home row or home keys. slouch in your chair
    9·2 answers
  • What are some of the ways you can use bitlocker encryption? (choose all that apply?
    10·1 answer
  • Any device that uses light to read and write information.
    9·2 answers
  • To obtain your class E learner license, youll need too _
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!