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
My name is Ann [436]
2 years ago
8

How to 5.4.4 on codehs?

Computers and Technology
1 answer:
iren2701 [21]2 years ago
3 0

The program is an illustration of the square function.

The square function takes a number, and returns the square of the number; i.e. the product of the number twice.

So, the square function in Python, where comments are used to explain each line is as follows:

#This defines the square function

def square(num):

   #This returns the square of the argument

   return num**2

   

#This gets input for the number

num = int(input("Number: "))

#This calculates the square of the number

x = square(num)

#This prints the square

print("Square:",x)

Read more about Python functions at:

brainly.com/question/25120954

You might be interested in
Which of these is system software? Check all
Darya [45]

Answer:

Windows OS is software....

6 0
3 years ago
Write a program that reads in an integer value for n and then sums the integers from n to 2 * n if n is nonnegative, or from 2 *
devlian [24]

Answer:

Following are the program in c++

First code when using for loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

for(i=n; i<=(2*n); i++)

{

sum1+= i;

}

}

else //  check if n  is negative

{

for(i=(2*n); i<=n; i++)

{

sum1+= i;

}

}

cout<<"The sum is:"<<sum1;

return 0;

Output

Enter the number: 1

The sum is:3

second code when using while loop

#include<iostream> // header file  

using namespace std; // namespace

int main() // main method

{

int n, i, sum1 = 0; // variable declaration

cout<<"Enter the number: "; // taking the value of n  

cin>>n;

if(n > 0) // check if n is nonnegative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

else //  check if n  is negative

{

int i=n;  

while(i<=(2*n))

{

sum1+= i;

i++;

}

}

cout<<"The sum is:"<<sum1;

return 0;

}

Output

Enter the number: 1

The sum is:3

Explanation:

Here we making 2 program by using different loops but using same logic

Taking a user input in "n" variable.

if n is nonnegative then we iterate the loops  n to 2 * n and storing the sum in "sum1" variable.

Otherwise iterate a loop  2 * n to n and storing the sum in "sum1" variable.  Finally display  sum1 variable .

4 0
3 years ago
Write a line of code to create a constant called MAX that will hold the size of an array that can store up to 25 decimal values.
Valentin [98]

Answer:

A line of code to create a constant called MAX that will hold the size of an array that can store up to 25 decimal values. Separate each item with 1 space, and end the line with a semi-colon.

Here,

const int MAX = 25;

7 0
2 years ago
You have implemented a network where each device provides shared files with all other devices, what kind of network is it?
Reil [10]

It is a Peer-to-peer type of network when you have implemented a network where each device provides shared files with all other devices.

So the answer is Peer-to-peer.

8 0
3 years ago
) Using newline command : endl
Pavlova-9 [17]

Answer:

The output of the code is following:-

My first C++ program.

The sum of 2 and 3 = 5

7 + 8 = 15

Explanation:

First the program should have #include<iostream>.This is missing in the program.

In the program you have printed My first C++ program first then used newline character endl. After that you have printed The sum of 2 and 3 = 5 this will be printed in the new line.Then you have used endl.Then printed  "7 + 8 = " string and the sum 7+8 that is 15.

Hence the output is like this.

6 0
3 years ago
Other questions:
  • I don’t know technically
    9·2 answers
  • Bullets in a text box will do which of the following?
    9·1 answer
  • in c Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the li
    14·1 answer
  • How is an amp meter connected in a circuit to measure flow of electrons
    15·2 answers
  • James gets a job at a multinational corporation. On his first day at work, he finds out that the numerical code assigned by the
    6·1 answer
  • What is the difference between "What I ought to do?" and "What kind of person should I be"?
    12·1 answer
  • Given a constant named size with a value of 5, which statement can you use to define and initialize an array of doubles named ga
    12·1 answer
  • Suppose that a 2M x 16 main memory is built using 256kB x 8 RAM chips and memory is word addressable, how many RAM chips are nec
    6·1 answer
  • Juan has performed a search on his inbox and would like to ensure the results only include those items with attachments which co
    14·2 answers
  • 31. Explain what the program does. Write out the output 20 PRINT "Hellooo00000000000, world!" 30 PRINT "I'm learning about comma
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!