Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language python code to copy thanks it needs to create a program that adds 1/2 and 1/3 No spac. Heading Heading 2 Title Subtitle Subtle

image text in transcribed

language python code to copy thanks

it needs to create a program that adds 1/2 and 1/3

No spac. Heading Heading 2 Title Subtitle Subtle Em... Emphasis Intense E... Styles The assignment is to create a program to create a program that adds the numbers 1/2 to itself and 1/3 to itself a large number of times. It is to then compare the values of adding the numbers to multiplying 1/2 and 1/3 times the number of times they were added. The program must first add 1/2 and 1/3, and compare to the value obtain using multiplication instead of addition, it is to do this for the following values: 1,000 10,000 100,000 1,000,000 10,000,000 100,000,000 1,000,000,000 The program should do this using two nested loops. The outer loop determines the number of times to add and starts at a 1000 and increments by multiples of 10 up to a 1,000,000,000. The inner loop does the addition of the numbers 1/2 and 1/3. When the inner loop completes, output the two sums (the) and the 1/3) and the two products, and the differences and continue the outer loop. Remember to clear your variables for the sums (accumulators) before the start of the inner loop. As always, have your name, the assignment number, and a brief description of the program in comments at the top, have comments in the program, use proper blocking, and make certain to test your program to verify that it is working properly This program is due Feb 11, 2020. Submit it to the Dropbox for assignment #2. Lastly, notice the values produced, do they make sense to you? The output should look something like this: The columns below are: Iterations 1/2 sum 1/2 product diff 1/3 sum 1/3 product 1000 500.0 500.0 0.0 333.33333333333184 333.3333333333333 -1.4779288903810084e-12 10000 5000.0 5000.0 0.0 3333.3333333337314 3333.333333333333 3.9835867937654257e-10 50000.0 50000.0 0.0 33333.33333328976 33333.33333333333 -4.3568434193730354e-08 1000000 500000.0 500000.0 0.0333333.3333322413 333333.3333333333 -1.092033926397562e-06 10000000 5000000.0 5000000.0 0.0 3333333.3337136623 3333333.333333333 0.00038032932206988335 100000000 50000000.0 50000000.0 0.0 33333333.28415699 33333333.333333332 -0.04917634278535843 1000000000 500000000.0 500000000.0 0.0 333333332.6651181 333333333.3333333 0.6682152152061462 Note that your difference on the 1/3 sum vs product may be different if you do the subtract in the opposite direction

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions