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

Sum of Numbers Design a function that accepts an integer argument and returns the sum of all the integers from 1 up to the numbe

r passed as an argument. For example, if 50 is passed as an argument, the function will return the sum of 1, 2, 3, 4, . . . 50. Use recursion to calculate the sum. Demonstrate the function in a program.
Engineering
1 answer:
cestrela7 [59]3 years ago
4 0

Answer:

# define main to get an argument from the user, call the function, and display the final values

def main():

 # ask an argument from the user.

 number = int(input('Enter a positive integer: '))

 # solve the integral thing of the number by putting the user's argument in the addition() function

 finalSum = addition(number)

 # display the final value integral thing

 print("The integral of this number is ", finalSum, ".")

# define an addition function to find the integral

def addition(num):

 # make an if-statement to test filter things out of your calculations. In this case, 1.

 if num == 1:

   #if 1, return 1. because 1 + (1 - 1) = 1

   return 1

 # this is where the recursion actually is. This is the part that calculates

 else:

   return num + addition(num-1)

# call your main function

main()

Explanation:

This is written in Python. A link to the output can be found below.

https://Sum-of-Numbers.hufflepuffler07.repl.run

You might be interested in
Steam enters a nozzle at 400°C and 800 kPa with a velocity of 10 m/s, and leaves at 300°C and 200 kPa while losing heat at a rat
jeyben [28]

Answer:606 m/s

Explanation:

Given

Steam Inlet temperature 400^{\circ} C and pressure 800 KPa

h_1=3267.7 kJ/kg

initial Velocity 10 m/s

Steam Outlet Velocity is 300^{\circ} C and pressure is 200 KPa

h_2=3072.1 kJ/kg

\nu _2=1.31632

From steam table

Heat loss 25  KW

inlet area 800 cm^2

applying Steady Flow Energy Equation

h_1+\frac{1}{2}v_1^2++Q=h_2+\frac{1}{2} v_2^2+W

3267.7+\frac{1}{2000}10^2-25=3072.1+\frac{1}{2000}v_2^2

3267.7-3072.1+0.05-25=\frac{1}{2}v_2^2

v_2=\sqrt{195.65\times 2}=606 m/s

and volume flow rate is m=\dot{m}\mu _2=2.082\times 1.31623=2.74 m^3/s

5 0
3 years ago
Read 2 more answers
about edubrainly. it seems it takes the questions from this website, C&P them, and also try's to get you to have viruses. ca
Y_Kistochka [10]

Answer:

yes

Explanation:

6 0
3 years ago
What song is this?
koban [17]

Answer:

heather by conan gray

Explanation:

3 0
4 years ago
Read 2 more answers
A window‐mounted air‐conditioning unit (AC) removes energy by heat transfer from a room, and rejects energy by heat transfer to
Arada [10]

Solution :

Given :

The power of the air‐conditioning (AC) unit is , W = 0.434 kW

The coefficient of performance or the COP of the air‐conditioning (AC) unit is given by  = 6.22

Therefore he heat removed is given by , $Q_H = 6.22 \times 0.434$

                                                                     $Q_H = 2.7 \ kW $

Now if the electricity is valued at  0.10 dollar per kW hour, then the operating cost of the air conditioning unit in 24 hours is given by = 0.10 x 2.7 x 24

                                                                                            = 6.48

Therefore the operating cost = $ 6.48 for 24 hours.

3 0
3 years ago
Teachers
IRINA_888 [86]
Uh I’m just gonna say yes because I think this is just something random
5 0
3 years ago
Other questions:
  • A meter stick can be read to the nearest millimeter and a travelling microscope can be read to the nearest 0.1 mm. Suppose you w
    11·1 answer
  • A town is designing a rectangular, 4m deep settling tank for treating surface water intake. The tank will have a flow velocity o
    14·1 answer
  • Two students are in a baseball game.The first student hits a ball very hard and it has a greater acceleration than the second st
    10·2 answers
  • What are the 5 basic types of propulsion systems​
    6·1 answer
  • What is the difference between gage pressure and absolute pressure?
    12·1 answer
  • Which happens when a wave passes through an opening
    12·2 answers
  • while performing a running compression test how should running compression compare to static compression
    5·1 answer
  • what is the relationship between the voltages of the output and adjust pins of LM1117 when in normal operation
    7·1 answer
  • In a morphological matrix, which of the following contains the parameters that are essential to a design?
    7·1 answer
  • Based on its atomic number, how many electrons does a hydrogen atom have
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!