Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python for this programming task, thank you Task 2: Collatz coniecture First create a file and save it as Week2_Task2. You will now write

image text in transcribedimage text in transcribed

Use python for this programming task, thank you

Task 2: Collatz coniecture First create a file and save it as Week2_Task2. You will now write a program that asks (prompts) the user to enter a positive value n. If n is even, divide n by 2. If n is odd, multiply it by 3 and add 1. Each time save the result back to n. Repeat the process until n is equal to 1. Hint: Use a WHILE loop For example: Enter the value for n: 12 12 6 3 10 16 8 4 Task 3: Heron's method of convergence In this task you will write a program to compute va using Heron's method of Convergence. At each iteration the new approximate value, Xnew, of Va is obtained from the old approximation, xold, by the following expression Your program should take as input a number, a, and an initial guess for the value of va and repeatedly apply equation 1 until the approximate solution converges to close to the true solution. (In this practical, you can assume that the convergence has occurred if |xold - Xnewl is less than 0.001 is For example: Enter the value for a: 25 Enter your initial guess for x: 100 25.31187655860349 13.14977760295123 7.525475220305588 5.4237622808967645 5.016554419368942 5.000027314445108 5.000000000074607 The square root of 25.0 is 5 74607 Task 4: Finding the nth root First create a file and save it as Weekl_Task4. Write a program that when given as input from the user a number x and value n will find the nth root of x. To make this task easier you will be required to import python's math library, see https://docs.python.org/3/library/math.html Background: The nth root of a number x can be determined by using the natural logarithm and exponents. Let a be the nth root of x, this gives x - a". Taking the logarithm of x gives, log(x) log(a") We know from our log laws that log(a") nlog(a). If we divide through (1) by n we get log(x) og loga) logx) - a = 10n log(x) Note: 10 is used as base for all my logs. If I used natural log then it should be e

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions