Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Program files x86 google drive googledrivesync exe

29/10/2021 Client: muhammad11 Deadline: 2 Day

Python Homework

Python Homework 3 Assigned: 12/3

Due: 12/7, 11:59pm

Possible Points: 100

Submit on Canvas a zip file containing your solution code for each problem (just the .py, .h, and .cpp files, please do not submit the solution/project files), turn in at least one .py and one .cpp file for each problem. Each problem specifies what you should title the file containing your solution so that the autograder can find it. Incorrectly named programs will not be graded and thus will get 0 points for the problem.

Since the assignment will be graded using an automated grading system you should have your program’s output match the sample output shown. If your program fails to run using Visual Studio 2017 it will receive zero points. If your program fails to run properly (runtime errors or wrong output) points will be deducted based on how correct is the program.

If you have any questions or concerns about the assignment do not hesitate to post on the discussion forum on canvas, send us message on canvas, or see us after class or during office hours.

Students are expected to write their source code from scratch, those who copy code from each other or web (including from Canvas examples) will be reported for cheating. We will also look at your code so do not just hard-code the answer and print it.

You have to write the solution both in Python and C++ (as exten- sion module). We recommend to first solve the problem in Python and then write the C++ extension code. Further, start with the pro- vided template. We will not penalize for 'self': unreferenced formal parameter warning. Additionally, the timings may differ, but we still expect you to match the formating, i.e, show the required number of significant digits. All input reading, timing, and printing must be done in Python.

1

1. Factorial: 10 points Files: factorial.py, factorialmodule.cpp

Compute a factorial of a given number, first in Python and then using C++ extension. The definition of a factorial of number n is as follows.

n! = n(n − 1)(n − 2)...1 (1)

Use int64_t in the C++ extension for the computations. In the wrapper function use PyLong_AsLongLong to convert from PyObject to int64_t and PyLong_FromLongLong to convert int64_t back to PyObject. Match the output format and use the provided timing code to measure the elapsed time for Python and C++ code.

Example Input

2 10 40

Expected Output

Case 0: Python: factorial of 10 is 3628800 Python: elapsed time 0.0056 ms C++: factorial of 10 is 3628800 C++: elapsed time 0.0112 ms Case 1: Python: factorial of 40 is 815915283247897734345611269596115894272000000000 Python: elapsed time 0.0073 ms C++: factorial of 40 is -70609262346240000 C++: elapsed time 0.0112 ms

2. Root Finding: 20 points File: root_finding.py, root_findingmodule.cpp

This assignment is to use Newton’s method to find the roots of an equation, starting the search at some point and finding the root to some desired accuracy or number of iterations. The equation you will be computing roots of is:

x5 + 6x4 + 3x3 − x − 50 (2)

2

Newton’s method works by starting from some (hopefully close) guess of the root and then iteratively updating it until we get close enough to the actual root of the equation. In other words, you iteratively compute the next best guess for the root using the following formula until convergence:

xn+1 = xn − f(xn) f ′(xn)

(3)

Your program does not need to compute f ′(x), instead compute the derivative by hand (or using WolframAlpha or however you prefer) and write the expression in your program. You can test for convergence by checking if xn+1 ≈ xn, specifically you should stop the root finding when the relative error has reached some threshold:

∣∣∣∣xn+1 − xnxn+1 ∣∣∣∣ ≤ ε (4)

or you have executed n iterations of the root finding method. You can find more information about Newton’s method on Wikipedia.

For computing absolute values, sine, cosine and powers you will want to use some of the functions in the cmath header (#include ), documented here.

The input to your program for each case will be the x value to start the search at followed by the number of iterations n and the tolerance ε. Your program should then find the root of equation (1) starting the search at x until the root is found to the desired tolerance or you have run the maximum number of iterations. When your program has found the root to within the desired precision or run out of iterations print it out to match the format below. Your program will need to run for at least one iteration to find the error between the guess and where we think the root is, even if the guess is exactly on.

You can reuse our/your solution from the previous homework.

Example Input

6 -5.2 100 1e-10 -1.0 100 1e-6 -5 1000 1e-10 1 10 1e-4 -7 100 1e-7 1 5 1e-10

Expected Output

3

https://en.wikipedia.org/wiki/Newton's_method
http://en.cppreference.com/w/cpp/header/cmath
Case 0: Python: root is -5.390653718237257 Python: elapsed time 0.0347 ms C++: root is -5.390653718237257 C++: elapsed time 0.0020 ms Case 1: Python: root is -5.390653718237257 Python: elapsed time 0.0188 ms C++: root is -5.390653718237257 C++: elapsed time 0.0017 ms Case 2: Python: root is -5.390653718237257 Python: elapsed time 0.0112 ms C++: root is -5.390653718237257 C++: elapsed time 0.0017 ms Case 3: Python: root is 1.5264066185662863 Python: elapsed time 0.0102 ms C++: root is 1.5264066185662863 C++: elapsed time 0.0017 ms Case 4: Python: root is -5.390653718237257 Python: elapsed time 0.0122 ms C++: root is -5.390653718237257 C++: elapsed time 0.0020 ms Case 5: Python: root is 1.5264080242772753 Python: elapsed time 0.0086 ms C++: root is 1.5264080242772753 C++: elapsed time 0.0026 ms

3. Lists: 30 points Files: lists.py, listsmodule.cpp

Implement a function that computes a sum of a given list both in Python and then as an extension in C++. Print the sum as in the example output and measure the time it took to compute the sum.

Implement a function that counts the occurences of a specified number in a list. The function needs to take two arguments, a list of numbers and a number for which to count occurrences. Print the output to match the example below.

Do not use built-in functions to compute the sum or count.

Documentation of list object manipulation functions

4

https://docs.python.org/3/c-api/list.html
Example Input

3 1 2 3 4 5 6 7 8 9 9 1 1 1 1 1 1 2 1 1 9 8 5 1 9 9 0 7

Example Output

Case 0: Python: sum 45 Python: elapsed time 0.0017 ms Python: 9 occurs 1 times Python: elapsed time 0.0122 ms C++: sum 45 C++: elapsed time 0.0119 ms C++: 9 occurs 1 times C++: elapsed time 0.0122 ms Case 1: Python: sum 8 Python: elapsed time 0.0010 ms Python: 1 occurs 6 times Python: elapsed time 0.0119 ms C++: sum 8 C++: elapsed time 0.0013 ms C++: 1 occurs 6 times C++: elapsed time 0.0017 ms Case 2: Python: sum 42 Python: elapsed time 0.0033 ms Python: 7 occurs 0 times Python: elapsed time 0.0013 ms C++: sum 42 C++: elapsed time 0.0010 ms C++: 7 occurs 0 times C++: elapsed time 0.0013 ms

4. Sudoku Solver: 40 points Files: sudoku_solver.py, sudoku_solvermodule.cpp and the provided files sudoku.py, sudoku.h without modifications

Use the provided sudoku solver (sudoku.py and sudoku.h) to solve sudoku

5

board both in Python and C++. If there is a solution, then convert it to a list of lists and return it back to Python where you print it in the format below. If there is no solution, return None. Represent the sudoku board as a list of lists, where each list is a row.

For the C++ extension you will need to convert sudoku board (list of lists) to the struct sudoku_board, pass it into the solver alongside another board’s pointer where the solution will be stored if found. Convert the solution (if any) back to list of lists and return it to Python interpreter. If there is no solution, return None and as for the Python solver print no solution.

Example Input

2 0 0 0 0 0 0 0 0 0 6 0 0 1 9 5 0 0 0 0 9 8 0 0 0 0 6 0 8 0 0 0 6 0 0 0 3 4 0 0 8 0 3 0 0 1 7 0 0 0 2 0 0 0 6 0 6 0 0 0 0 2 8 0 0 0 0 4 1 9 0 0 5 0 0 0 0 8 0 0 7 9 6 0 0 0 0 0 0 0 0 6 0 0 1 9 5 0 0 0 0 9 8 0 0 0 0 6 0 8 0 0 0 6 0 0 0 3 4 0 0 8 0 3 0 0 1 7 0 0 0 2 0 0 0 6 0 6 0 0 0 0 2 8 0 0 0 0 4 1 9 0 0 5 0 0 0 0 8 0 0 7 9

Expected Output

Case 0: Python: 3 4 5 6 7 8 9 1 2 6 7 2 1 9 5 3 4 8 1 9 8 3 4 2 5 6 7 8 5 9 7 6 1 4 2 3 4 2 6 8 5 3 7 9 1 7 1 3 9 2 4 8 5 6 9 6 1 5 3 7 2 8 4 2 8 7 4 1 9 6 3 5 5 3 4 2 8 6 1 7 9 Python: elapsed time 960.8519 ms C++:

6

3 4 5 6 7 8 9 1 2 6 7 2 1 9 5 3 4 8 1 9 8 3 4 2 5 6 7 8 5 9 7 6 1 4 2 3 4 2 6 8 5 3 7 9 1 7 1 3 9 2 4 8 5 6 9 6 1 5 3 7 2 8 4 2 8 7 4 1 9 6 3 5 5 3 4 2 8 6 1 7 9 C++: elapsed time 9.8189 ms Case 1: Python: no solution Python: elapsed time 224.6007 ms C++: no solution C++: elapsed time 2.1440 ms

7

Python Homework 3
1. Factorial: 10 points
2. Root Finding: 20 points
3. Lists: 30 points
4. Sudoku Solver: 40 points

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Assignments Hut
Quick N Quality
Quality Homework Helper
Accounting & Finance Mentor
Top Quality Assignments
Engineering Solutions
Writer Writer Name Offer Chat
Assignments Hut

ONLINE

Assignments Hut

I am a PhD writer with 10 years of experience. I will be delivering high-quality, plagiarism-free work to you in the minimum amount of time. Waiting for your message.

$41 Chat With Writer
Quick N Quality

ONLINE

Quick N Quality

After reading your project details, I feel myself as the best option for you to fulfill this project with 100 percent perfection.

$34 Chat With Writer
Quality Homework Helper

ONLINE

Quality Homework Helper

I am an experienced researcher here with master education. After reading your posting, I feel, you need an expert research writer to complete your project.Thank You

$37 Chat With Writer
Accounting & Finance Mentor

ONLINE

Accounting & Finance Mentor

I have read your project description carefully and you will get plagiarism free writing according to your requirements. Thank You

$30 Chat With Writer
Top Quality Assignments

ONLINE

Top Quality Assignments

I reckon that I can perfectly carry this project for you! I am a research writer and have been writing academic papers, business reports, plans, literature review, reports and others for the past 1 decade.

$17 Chat With Writer
Engineering Solutions

ONLINE

Engineering Solutions

I am a PhD writer with 10 years of experience. I will be delivering high-quality, plagiarism-free work to you in the minimum amount of time. Waiting for your message.

$35 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Construct viable arguments and critique the reasoning of others - Week 3 quiz information - Isaac newton interview questions - Does siemens own bosch - Boron 10 and boron 11 which is more abundant - Post- Jenny - Com 201 - Karyotyping web activity answer key - Project - 19 55 in 12 hour clock - Health declaration form for employment - Ap worksheet 03g quantitative analysis answers - Time complexity avl tree - How to find the percentile rank of a score - Examples of sizzling starts - Los cajeros cuentan los palillos para saber cuánto deben pagar los clientes - Urgent - Printable screw size chart - Family the building block of society - Nursing - One page, MLA Format - Essay guru only 1 - Hive 2 channel receiver - Example of behavior modification program paper - Episodic soap note sample - Outline - Match the following terms with their definitions - Anle corporation has a current stock price of - Give me liberty 5th edition pdf volume 2 - How to get rid of stags bluekai on mac - Freud museum london jobs - Project management - Research Paper - Comprehensive women's health soap note - Psychology In The World - Final (Essay) - Ironport messaging gateway appliance - Discussion - Pattern design software free - Case 3 walmart manages ethics and compliance challenges answers - How to write a text response - How to build a half wave rectifier - Www ccp14 ac uk - English 3 - Unified communications at boeing case study - Reduction of aldehyde with nabh4 - Intermolecular forces answer key - 92 golden rules of success hiroshi mikitani - Ritz carlton five star employee award - Research Customer Service Policies - Individual healthcare identifier number - Advantages and disadvantages of rock armour - Brainpop carbon cycle worksheet answers - Team performance productivity and rewording teamwork - Nmc revalidation forms combined - The fluid mosaic model describes the _____ - Acct research - The sears tower in chicago is feet tall - Adelaide to naracoorte bus timetable - The innocent anthropologist chapter summaries - HOMEWORK - Isentropic efficiency of steam turbine - Assignment #088 - Fife online referral tracking system - Executive Summary - Article Review exercise - Chromatography exercises with answers - Built environments unit of work - Dry drayton primary school - Which artist is considered the primary forerunner of rockabilly music? - Criminal justice work - Heliplane aircraft 18a gyroplane - Managing Criminal Justice Organizations - Thesis statement for net neutrality - Implement and monitor environmentally sustainable work practices - Quality points for vegetables - Demographic transition model worksheet - Museum design ppt - Addition of force vectors lab answers - Which of the following statements is true about whistleblowing - Fiero gloria k the humanistic tradition - Faithful one so unchanging chords - Billy joel pressure ringtone - NURS561REPLYPROMPT1 - Structural family therapy assessment tools - Ipswich indoor sports centre - Riverside medical practice cuxton - Bronch o is a combining form meaning - MT 10 - Chapter 13 strategy balanced scorecard and strategic profitability analysis - Cheat the warriors ps2 pistol - Human Service Discussion Question - AMP 2 - Psychotherapy a Biological Basis - Triage assessment model crisis intervention - Pmd pro level 1 - Cross site scripting xss attack lab elgg - Reply to my peer - Stewardship (Environmental Science) - POL101-2 - What is worldcat penn foster