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
Where did the name "QWERTY" come from?​
weqwewe [10]

Answer:

From the keyboard layout invented by Christopher Lathem Sholes. It is now the most used keyboard layout throughout the world

4 0
3 years ago
Create the SQL statements for displaying the results for each of the following scenarios in the Academic Database. Save these st
Whitepunk [10]

Answer:

CREATE FUNCTION exam_eligible_students

   RETURN NUMBER AS

   num_students NUMBER(15);

BEGIN

   SELECT COUNT(STUDENT_ID)

   INTO num_students

   FROM STUDENT_ATTENDANCE

   WHERE ELIGIBILITY_FOR_EXAMS = 'Y';

   

   RETURN (num_students);

END;

Explanation:

exam_eligible_students is a made of name for the FUNCTION to be called.

num_students is a made up name for the RETURN to be called. The RETURN name is referenced in the INTO statement and as the name of the the return in the RETURN line in ().

4 0
3 years ago
How many passes will it take to find the four in this list?
earnstyle [38]

Answer:

3 is the correct answer

I got correct on my test

7 0
3 years ago
Read 2 more answers
Suppose you want to view a document that has several headings. what view would you use?
bija089 [108]
Um i think outline. :)
5 0
3 years ago
1.Which of the serves as the basis for determining whether an object has moved or not?
Harrizon [31]

Answer:

1. b

2. c

3. b

4. d

5. a

(hope this helped)

4 0
2 years ago
Other questions:
  • What is faster a hi-speed usb port or superspeed usb port?
    13·1 answer
  • In a program called Nature's Notebook, citizen volunteers make and report observations about seasonal changes in plants and anim
    15·1 answer
  • Discuss what they need to consider if they wish to use their devices when they are away from home?
    6·1 answer
  • Consider the provided C++ code in the main.cpp file: The function func2 has three parameters of type int, int, and double, say a
    8·1 answer
  • A girl scout troop with 10 girl scouts and 2 leaders goes on a hike. When the path narrows, they must walk in single file with a
    12·1 answer
  • Dustin runs a command at the command line trying to find out what kernel version the system is running. However, it doesn't give
    12·1 answer
  • Short Essay on the history of Computer​
    6·2 answers
  • What type of account provides the same functions as managed service accounts but can be managed across multiple servers as in a
    8·1 answer
  • Which task would most likely be completed by a physician’s assistant?
    12·1 answer
  • An electronic element that stores data by changing its resistance based on the current that has passed through it (similar to RR
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!