Let us worry about your assignment instead!

We Helped With This Python Programming Assignment: Have A Similar One?

More InfoPython Assignment

Short Assignment Requirements

This assignment is used in PyCharm and using the Anaconda 3 package.

Assignment Description

COSC 120: HW#2

Dr. Fred Park, Whittier College

1.    Comparison of two program outputs: Write a loop using 100,000 iterations. In the loop, for each iteration, create a 1×10 numpy array and use the ‘randint’ function from the random module and input random numbers from 0 to 9 into each array location. Call it x. Run your bubble sort code from class to sort this length 10 array x into ascending order and store it each iteration. In this same iteration, use the ‘sorted’ function from numpy to sort the x array . Calculate the difference between these arrays (which will give you another length 10 array), sum that difference array and store that value in a difference vector of length 100,000. At the termination of the loop, sum the difference vector. If your bubble sort is correct, the sum should equal zero.

2.    The Monty Hall Problem: Here we will investigate this famous probability phenomenon. Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you,“Do you want to pick door No. 2?” Is it to your advantage to switch your choice?”

Write a simulation in python of the Monty Hall problem based on two strategies. One where you always switch and one where you always stay at your first choice door. Do this for 10,000,000 (10 million) trials. What is the experimental probability in each case? Does the outcome agree with your calculation of the theoretical probability?

3.    Cleaning Data: Let s be a string that contains a sequence of decimal numbers separated by commas, but somehow the data is corrupted and a random * shows up either right after a comma, before a comma, or before the first term of an integer number. e.g. (that’s exempli gratia, latin abbreviation of ‘for example’) s = ‘1.23,*2.4*, 3.123,*5.1, 8.7*, *7.23, *3.23*’. Write a program that prints the sum of the numbers in the string s. Note, the whitespace is unevenly distributed in the string as well. You cannot use any built in functions or methods associated to the string object.

4.    Prime Number Generation: A prime number is a number that is only divisible by itself and 1.

e.g the number 2 is prime, so is 3, but 4 = 2×2 is not. In general, if a number looks prime, then it usually ends up being prime. For example, 1997 is prime and it looks prime. However, this is not a rigorous theorem and the distribution of prime numbers is a concept beyond the scope of this course.

(a)    Write code that prints out all the prime numbers from 1 to 100. Can you do the same forany number N that is input by a user? Write code that does this as well.

(b)    Write code that prompts a user to enter an integer N and print out that many primes.

(c)    Write code that prompts a user to enter an integer and print out that many twin primes.Twin primes are primes that differ by 2. e.g. (3, 5) are twin primes.


5.    Goldbach’s Conjecture Goldbach’s Conjecture states that any even number larger than 2 can be written as the sum of two primes. e.g. 12 = 5 + 7. Write code that prompts a user to enter an even integer and outputs the two primes that sum to it. Format your output so that you get the decomposition on the screen. e.g. you should print out “12 = 5 + 7” on the screen in one enters 12. You should also build in error checking to make sure a positive even integer is entered, otherwise ask the user to re-enter.

6.    Lists:

a.    Generate a random list of numbers of length N where N is input by the user. Calculate themean and median of the numbers from this list. Note, we are using the data structure ‘list.’

b.    Write a bubble sort algorithm that operates on a list of arbitrary numbers.

c.    Write code that sorts a list of names into alphabetical order.

7.    Guess the Number Game:

a.    Write code that generates and stores a random number. Prompt the user to guess what thenumber is.

b.    If the number is wrong, indicate whether the guess was too high or low and prompt the userto guess again. If it was guessed correctly, you should output a message of that sort. You may give the user multiple tries. Make sure to print an error message if the value entered by the user is not a number and should prompt the user to re-enter a number.

8.    Newton’s Method Implement Newton’s method to find a zero of a polynomial.

(a)    Show that it converges in fewer steps than the bisection algorithm from class by testing onf(x) = x2 − 2 for x0 = 1.

(b)    Can you use it to find the root of f(x) = x2 − 2x + 1 for x0 = 0? How iterations until you get |f(x)| < 10−6 where xis the approximated root?


Frequently Asked Questions

Is it free to get my assignment evaluated?

Yes. No hidden fees. You pay for the solution only, and all the explanations about how to run it are included in the price. It takes up to 24 hours to get a quote from an expert. In some cases, we can help you faster if an expert is available, but you should always order in advance to avoid the risks. You can place a new order here.

How much does it cost?

The cost depends on many factors: how far away the deadline is, how hard/big the task is, if it is code only or a report, etc. We try to give rough estimates here, but it is just for orientation (in USD):

Regular homework$20 - $150
Advanced homework$100 - $300
Group project or a report$200 - $500
Mid-term or final project$200 - $800
Live exam help$100 - $300
Full thesis$1000 - $3000

How do I pay?

Credit card or PayPal. You don't need to create/have a Payal account in order to pay by a credit card. Paypal offers you "buyer's protection" in case of any issues.

Why do I need to pay in advance?

We have no way to request money after we send you the solution. PayPal works as a middleman, which protects you in case of any disputes, so you should feel safe paying using PayPal.

Do you do essays?

No, unless it is a data analysis essay or report. This is because essays are very personal and it is easy to see when they are written by another person. This is not the case with math and programming.

Why there are no discounts?

It is because we don't want to lie - in such services no discount can be set in advance because we set the price knowing that there is a discount. For example, if we wanted to ask for $100, we could tell that the price is $200 and because you are special, we can do a 50% discount. It is the way all scam websites operate. We set honest prices instead, so there is no need for fake discounts.

Do you do live tutoring?

No, it is simply not how we operate. How often do you meet a great programmer who is also a great speaker? Rarely. It is why we encourage our experts to write down explanations instead of having a live call. It is often enough to get you started - analyzing and running the solutions is a big part of learning.

What happens if I am not satisfied with the solution?

Another expert will review the task, and if your claim is reasonable - we refund the payment and often block the freelancer from our platform. Because we are so harsh with our experts - the ones working with us are very trustworthy to deliver high-quality assignment solutions on time.

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On

soc fb soc insta

Paypal supported