Programming exercise - tayler expansion

Assignment Help Python Programming
Reference no: EM133059365

Learning Activity: Programming Exercises

Exercise 1. Prime number (Advanced)

From the last learning activity, you learnt how to determine whether a particular number is a prime number. In this learning activity, you will write a Python program that outputs all prime numbers from 1 to a given number. The program will first ask the user to type in a positive number, then output all the prime numbers from 1 to that number (inclusive), separated by comma.

Sample input/output:
>>> Enter a positive number:
>>> 100
>>> 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

This learning activity asks you to write a program.
Please upload your code as a Python code file (.py file) to Module 3.2 Programming Exercises - Difficult Discussion Forum and do not copy and paste your code in the discussion forum text editor as the indentation may be lost. Indentations in Python indicate code blocks and scope and is part of the code.

Please check other students' code and comment on why you agree, disagree or can provide help with another students' post. Please reply to at least two other students' posts.

Exercise 2. Tayler expansion

In this exercise, you are going to write a Python program that approximate the first n terms of the following equation:

1 + 2/1! + 22/2! + 23/3! + 24/4! ......,

where m! is the factorial of m, that is,

m! = 1 × 2 × 3 × ... × m

For example, 5! = 120 (the production from 1 to 5). 10! = 3628800.

Now write a Python program that allows the user to type in an integer n, your program then calculate the first n terms of the summation in the equation. For example, if the user type in 3, you then need to calculate the result of the first 3 terms:

1+ 2/1! + 22/2! = 1 + 2 + 2 = 5

If the user type in 4, you then need to calculate the result of the first 4 terms:

1+ 2/1! + 22/2! + 23/3! = 1 + 2 + 2 + 1.33 = 6.33

Sample input/output 1:
>>> Enter an integer:

>>> 3

Sample input/output 2:

>>> Enter an integer:
>>> 4
>>> 6.33

This learning activity asks you to write a program.

Reference no: EM133059365

Questions Cloud

Calculate and provide a brief cost-benefit analysis : While Financial Services industry is not much impacted from the Carbon Tax compared to other industries, Calculate and provide a brief cost-benefit analysis
Programming exercise - remove duplicates in a list : Programming Exercise - Remove duplicates in a list - Implement an algorithm that removes duplicated elements in a list
What is the ocf for this project : The project is estimated to generate $3,250,000 in annual sales, with costs of $2,270,000. If the tax rate is 22 percent, what is the OCF for this project
Determine each project payback and NPV : The cost of capital is 10%, and Garneau usually requires projects to have a payback within four years. Determine each project's payback and NPV
Programming exercise - tayler expansion : Programming Exercise - Tayler expansion - how to determine whether a particular number is a prime number. In this learning activity
What is the contribution margin per unit and ratio : The accountant has provided Tupac with the following data to prepare next year's campaign. What is the contribution margin per unit and ratio for 2022
Calculate the payback period of the new machine : The net cost of this machine is $250,000 and is expected to have a useful life of 5 years, Calculate the payback period of the new machine
Calculate the change in operating profit due to productivity : Factory support costs do not vary with the actual number of motors made that year. Calculate the change in operating profit due to productivity
Programming exercise - prime number : Programming Exercise - Prime number - write a Python program that determines whether a user's input is a prime number or not

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd