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
Write the program to solve quadratic equations, but if the discriminant is negative, output
Firdavs [7]

Answer:

PROGRAM  QuadraticEquation Solver

  IMPLICIT  NONE

REAL :: a, b, c ;

  REA :: d ;

  REAL  :: root1, root2 ;

//read in the coefficients a, b and c

  READ(*,*)    a, b, c  

  WRITE(*,*)   'a = ', a

  WRITE(*,*)   'b = ', b

  WRITE(*,*)    'c = ', c

  WRITE(*,*)

// computing the square root of discriminant d

  d = b*b - 4.0*a*c

  IF (d >= 0.0) THEN              //checking if it is solvable?

     d     = SQRT(d)

     root1 = (-b + d)/(2.0*a)     // first root

     root2 = (-b - d)/(2.0*a)     // second root

     WRITE(*,*)  'Roots are ', root1, ' and ', root2

  ELSE                            //complex roots

     WRITE(*,*)  'There is no real roots!'

     WRITE(*,*)  'Discriminant = ', d

  END IF

END PROGRAM  QuadraticEquationSolver

8 0
3 years ago
Is a display, or monitor, considered a piece of computer hardware
9966 [12]
Yes. The monitor is considered as a piece of Computer Hardware. Computer hardware is what you can physically touch, like the keyboard, mouse, monitor, disk drive, and so on.

I hope this answers your question.

Thank you,
Otaku
3 0
3 years ago
These statements describe guidelines for the use of tables in presentations.
In-s [12.5K]

Answer:

(E)

Explanation:

I think it's E because it's the only answer that makes sense I guess!

4 0
3 years ago
Read 2 more answers
What is the full form of flops​
kobusy [5.1K]

Answer:

<em>Floating Point Operations Per Second</em> (FLOPS)

Explanation:

<em>Floating Point Operations Per Second</em> (FLOPS) is a measure of a computer’s performance, especially in fields of scientific calculations that make heavy use of floating-point calculations. Floating-point operations include any operations that involve fractional numbers.

8 0
3 years ago
Read 2 more answers
What type of servers are used to store recently accessed DNS records from other domains to avoid incurring the performance overh
Kruka [31]

The correct answer is B. Primary DNS Server.

DNS records are type of data that is equivalent to IP address where the website or domain is located.  DNS records are normally stored in DNS server in a raw or flat file. A host, using port number 53 will send a DNS request to the server. If the computer has stored it's data or record in it's database, it will automatically reply to the requesting host. Example: You typed in www.website.com, if you have a matching DNS record in your server, using an IP address, your server will reply and display the website.

8 0
3 years ago
Other questions:
  • Which of the following is NOT a destination?
    12·2 answers
  • The array s of ints contain integers each of which is between 1 and 1000 (inclusive). write code that stores in the variable ord
    9·1 answer
  • If an M/M/1 queue in a server has task arrivals at a rate of 30 per second and serves at a rate of 50 per second, how many tasks
    10·1 answer
  • What is network management?
    12·1 answer
  • Write a program that takes paragraph from the user and prints all unique words in that paragraph using strings in c++
    5·1 answer
  • The power relationship on a transformer states that O Power in = power out + loss O Power in = 1/2 power out (Power in = 2 x pow
    5·1 answer
  • Which function would you use to make sure all names are prepared for a mailing label? TODAY UPPER PROPER LOWER
    11·1 answer
  • .....is used to save project in Visual basic .net from file menu
    6·1 answer
  • Write any four causes of cyber crime
    12·1 answer
  • Define foreign employment​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!