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

  Design and develop a prototype product

Design and develop a prototype product that uses Internet of Things technologies for environmental monitoring. Generally, IoT products collect data observed

  Create a while loop that prints that number doubled up to

Create a while loop that prints that number doubled up to, but without exceeding 100. Follow each number with a space.

  Simulates a simple money manager

Provide a login screen to prevent other people from viewing the information contained in the tool - view the current balance funds, add purchases made

  What will be displayed after the code runs

Assuming the random module has been imported into its default namespace, which of the following could be used to generate a random even integer.

  Need a python function that will accept as input strings

Need a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the first two strings.

  Write the pseudo code and then code it in python

Write the pseudo code and then code it in Python. Write a function that has number of tosses as an input parameter. As usual, screen copy your code and results.

  Write a program to conversate with the user

Write a program to conversate with the user. The program must ask for both strings and numbers as input.

  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.

  Create a class hand in its own module

Create a class Hand in its own module. One object of class Hand represents a hand of cards and so one object stores a number of Card objects.

  Write a function range that accepts a list of lists

Write a function range that accepts a list of lists as a parameter and that returns the range of values contained in the list of lists, which is defined .

  Write python code to print true

Given two lists, write python code to print "True" if the two lists have at least one common element. For example, x = [1,2,3], y=[3,4,5], then the program.

  Describe why are the values of f and g different

Describe specifically and why are the values of f and g different? Support your experimentation with a screen capture of executing the code.

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