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
A proposed embankment fill requires 7100 ft of compacted soil. The void ratio of the compacted fill is specified as 0.5. Four bo
podryga [215]

Answer:

1) the volume of solid (Vs) is 4733.33 ft³

2) the total cost to pay Pit A is $58220

3) the total cost to pay to Pit B is $53344.67

4) the total cost to pay to Pit C is $34269.32

5) the total cost to pay to Pit D is $49132.02

Explanation:  

given the data in the question;

Vs = ?, V = 7100 ft³, e = 0.5

1) Calculate the volume of solid (Vs)

Vs = V / ( 1 + e )

we substitute

Vs = 7100 / ( 1 + 0.5 )

Vs = 7100 / 1.5

Vs = 4733.33 ft³

Therefore, the volume of solid (Vs) is 4733.33 ft³

2) Calculate the total cost to pay to Pit A

VpitA / Vcomp = ( 1 + e_{PHA}) / ( 1 + e_{comp )

we substitute

VpitA / 7100 = ( 1 + 1.5) / ( 1 + 0.5)

VpitA / 7100 = 1.3666666

VpitA = 1.3666666 × 7100

VpitA  = 9703.33 ft³

Total cost = volume × unit cost = 9703.33 ft³ × 6 = $58220

Therefore, the total cost to pay Pit A is $58220

3) Calculate the total cost to pay to Pit B = Borrow Pit C: void ratio = 0.81 and the unit cost = $ 4 /ft3

Vpitb / Vcomp = ( 1 + e_{PHB}) / ( 1 + e_{comp )

we substitute

VpitB / 7100 = ( 1 + 0.61) / ( 1 + 0.5)

VpitB / 7100 = 1.0733333

VpitB = 1.0733333 × 7100

VpitB  = 7620.666 ft³

Total cost = volume × unit cost = 7620.666 × 7 = $53344.67

Therefore, the total cost to pay to Pit B is $53344.67

4) Calculate the total cost to pay to Pit C = Borrow Pit D: void ratio = 0.73 and the unit cost = $6 /ft3

VpitC / Vcomp = ( 1 + e_{PHC}) / ( 1 + e_{comp )

we substitute

VpitC / 7100 = ( 1 + 0.81) / ( 1 + 0.5)

VpitC / 7100 = 1.2066666

VpitC = 1.2066666× 7100

VpitC  = 8567.33 ft³

Total cost = volume × unit cost = 8567.33 × 4 = $34269.32

Therefore, the total cost to pay to Pit C is $34269.32

5) Calculate the total cost to pay to Pit D

VpitD / Vcomp = ( 1 + e_{PHD}) / ( 1 + e_{comp )

we substitute

VpitD / 7100 = ( 1 + 0.73) / ( 1 + 0.5)

VpitD / 7100 = 1.1533333

VpitD = 1.1533333 × 7100

VpitD  = 8188.67 ft³

Total cost = volume × unit cost = 8188.67 × 6 = $49132.02

Therefore, the total cost to pay to Pit D is $49132.02

3 0
3 years ago
6. Question
valkas [14]

Answer:

Check  the 2nd, 3rd and 4th statements.

Explanation:

4 0
3 years ago
True or false? Engineering degree programs and engineering technology degree programs have a different requirements
sergey [27]
That’s true brother
4 0
3 years ago
In a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their
joja [24]

Answer:

Three ways that engineers explore possible solutions in their projects are;

1) Prototyping

2) Simulation

3) Calculations

Explanation:

1) Prototyping is the process of experimental testing of samples of design, or model of a product with the possibility of the inclusion of control of parameters in order to determine the workability of a solution.

2) Simulation is the process of creating an imitation of a situation, operation or process which can be used to determine if a particular solution will be able to work as required in the simulated environment of a problem.

3) Calculations are used to find preliminary results of particular situations, their cause and effects based on scientific laws, theories and hypothesis such that the factor of the problem is equated with the available ideas to find the best possible solution.

3 0
3 years ago
Need Answers Quick!!!! What is the purpose of structural components such as frames, bearings, and mounts? A.) Connect two rotati
elixir [45]

Answer:

D.) Transfer input energy from the power source throughout the machine.

Explanation:

Since the complex abnormalities of energy efficiency is depicted by the autonomy within self-operating machines, the correct answer is D.

3 0
3 years ago
Other questions:
  • 11 Notează, în caiet, trăsăturile personajelor ce se pot
    13·1 answer
  • 1. What is an op-amp? List the characteristics of an ideal op-amp
    11·1 answer
  • Which tool is used to pull the tapered shaft on a tie-rod end from its mating steering component?
    9·1 answer
  • Early American rockets used an RC circuit to set the time for the rocket to begin re-entry after launch (true story). Assume the
    5·1 answer
  • The flow curve for a certain metal has parameters: strain-hardening
    8·1 answer
  • Consider a 0.15-mm-diameter air bubble in a liquid. Determine the pressure difference between the inside and outside of the air
    10·1 answer
  • Plot da(t) if the output voltage of the converter pole-a is vaN(t)=Vd/2+0.85 Vd/2 sin(Ï1t), where Ï1=2Ï x 60 rad/s
    12·1 answer
  • What parts do all circuits have in common?
    9·2 answers
  • Need help, I will give cake :))<br><br> + branliest
    14·2 answers
  • (CO 3) A nonrecursive filter may best be described as _____. Group of answer choices a filter whose current output depends on pa
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!