1001 Freelance Projects
Latest Projects from Freelance Marketplaces
Today is: 18-May-2024 07:41 GMT
View Project
View this project in detail (Note: you will be redirected to external marketplace)
Project title: Python Programming a Lab
Posted by: External project from PeoplePerHour
Started: 11-Dec-2020 03:12 GMT
Description: Expected duration: less than 1 week
I need a Python Programmer to program a Lab for school for me. It has a criteria that has to be followed and has to be correct and sent in for a grade.

Below is the Criteria: Please look over and follow.

Numeric Integration!
There is a good chance you won't finish this lab in two hours; but math isn't supposed to be the sticking point; watch the lecture video first!

In class we looked at a numeric integration method that summed the area of either rectangles or trapezoids (rectangles topped with triangles).

We also wrote a simple python program which graphed a function using the textbook's graphics library.

For this lab I want you to modify that program to draws rectangles and computes the integral of the sine function. Call your program sinarea.py

In python you can get the value of sine(x) by import math and then calling math.sin(x) (See the text chapter 3 to see an example of importing math functiions.) Note that the value of x and that returned are in radians.

To start, copy my program (above), rename it sinarea.py and modify it to plot only the sine function. (You'll also need a copy of the graphics.py code in your working directory.)

Change the header to add your information indicating you modified my code.

When you look at the (four) math functions I coded, you'll see a disconnect between the comments (that talk about N/100) and the actual code (that uses 130 instead.) That's often a problem - when I changed the code in class, I failed to update my comment to match. Bad example!

You'll want to delete my four math functions and replace them with a wrapper for the math.sin function. The goal of your wrapper is to return a value that fits nicely in our graphics window that expects to plot values between 0 and 1.

The nice thing about the sin function is that over certain ranges it naturally returns values between 0 and 1 (for example, when X is between 0 and math.pi):


The math.sin function expects its actual parameter to be in radians. You might know that math.pi radians = 180 degrees, or 1 radian = 180 / math.pi degrees - but the important thing is that the X axis on the above graph has radians as its unit - so as long as we plotour function between 0 and pi we'll get a curve with a Y value ranging from 0 to 1. To make things simple, for this lab, let's assume endpoints (lower, upper)are always in the range (0, pi). This means your wrapper function merely needs to call math.sin:


def sine(n):
return math.sin(n)
After you write the new sin wrapper function, you should stop and test your program.

Unfortunately, the range function I used in my for loops doesn't allow floating point numbers, i.e.

for lc in range(0,math.pi,0.1):

generates

TypeError: 'float' object cannot be interpreted as an integer.

This is a good time to substitute a while loop:



lower = 0
upper = math.pi
step = 0.01

lc = lower
while (lc < upper):
nextpoint = Circle(Point(12+lc*5,yspot(sine(lc))),2)
nextpoint.setOutline("red")
nextpoint.setFill("red")
nextpoint.draw(win)
lc = lc + step

This works, but the X value is too compressed - the formula 12+lc*5 needs to be changed to spread the values (0, pi) over the range (12, 510). Adjust your code to do that.

Next, rather than drawing circles, change your code to plot rectangles. Examples using our graphics.py librarys to plot rectangles can be found in our textbook. They'll be easier to see if you don't fill them.

Test your program. Working, it will draw the same number of rectangles every time.

Next, modify your program to take the number of rectangles as input

You'll need to calculate your width of each rectangle (the step) by:

(upper - lower) / number of rectangles

And now your should loop between lower and upper with your calculated step, calling math.sin(lc) and using that value to draw each rectangle.

Finally, add code to calculate (sum) the area of all the rectangles within your loop. Inside the loop, each rectangle you draw has the area of its math.sin(lc) value times its width (the step). Print out this result. As you increase the number of rectangles, the results will be more accurate.

You can check your answer by comparing it with the definite integral:




In other words, if you use lower = 0 and upper = 3.14159 and the sin function you should get about 2.0.

Need to be done soon as possible.
Project ID: 3119072
Project category:
Project budget:
View this project in detail (Note: you will be redirected to external marketplace)
Last Projects / Browse Projects
  Project Started
CAD Designer for Comprehensive Machine Design -- 2
Category: 3D Modelling, CAD / CAM, Manufacturing Design, Product Design, Solidworks
Budget: ₹1500 - ₹12500 INR
18-May-2024
04:04 GMT
Literary Fiction Short Story Editing
Category: Creative Writing, Editing, Fiction, Poetry, Proofreading
Budget: $10 - $30 USD
18-May-2024
04:04 GMT
PC Action Game Testing -- 2
Category: Software Testing, Test Automation, Testing / QA, Usability Testing, Website Testing
Budget: $10 - $30 USD
18-May-2024
04:04 GMT
Social Media Intern Required
Category: BPO, Data Entry, Excel, Facebook Marketing, Social Media Marketing
Budget: ₹100 - ₹400 INR
18-May-2024
04:04 GMT
Desarrollador Odoo Experto -- 2
Category: Django, ERP, Odoo, PostgreSQL, Python
Budget: $2 - $8 USD
18-May-2024
04:04 GMT
Advanced AR Headset Development
Category: Android, Game Development, IPhone, Matlab And Mathematica, Mobile App Development
Budget: ₹500000 - ₹1000000 INR
18-May-2024
04:03 GMT
WooCommerce eCommerce Site with Custom Design (FLS Project)
Category: ECommerce, HTML, PHP, Web Design, WordPress
Budget: $30 - $250 SGD
18-May-2024
04:01 GMT
Promotional Videography for Music Fans
Category: Audio Services, Cinematography, Editing, Lighting, Video Services
Budget: $30 - $250 USD
18-May-2024
04:00 GMT
Loan Processing Optimization for DSCR
Category: Accounting, Business Analysis, Business Plans, Finance, Research Writing
Budget: $2 - $8 USD
18-May-2024
03:59 GMT
3D visualization of the fair
Category: 3D Animation, 3D Modelling, 3D Rendering, 3ds Max, AutoCAD
Budget: €30 - €250 EUR
18-May-2024
03:58 GMT
Wix Website Content & Functionality Upgrade
Category: BigCommerce, HTML, PHP, Web Design, Wix
Budget: $250 - $750 CAD
18-May-2024
03:57 GMT
Urgent UI Design for Landing Page -- 2
Category: Graphic Design, HTML, PHP, User Interface / IA, Web Design
Budget: $10 - $30 AUD
18-May-2024
03:55 GMT
Retail Market Research Specialist in Mexico
Category: Business Analysis, Internet Marketing, Market Research, Marketing, Research
Budget: $30 - $250 USD
18-May-2024
03:54 GMT
Logo Design for Qur'an YouTube Channel
Category: Banner Design, Graphic Design, Illustration, Logo Design, Photoshop
Budget: $30 - $250 USD
18-May-2024
03:52 GMT
TradingView Pine Script Analyst Needed -- 3
Category: Metatrader, Pine Script, Trading
Budget: $10 - $30 USD
18-May-2024
03:52 GMT
Browse All Projects
Projects by Skills ...
Projects for 'android'
Projects for 'ajax'
Projects for 'asp'
Projects for 'aspnet'
Projects for 'cms'
Projects for 'cpp'
Projects for 'csharp'
Projects for 'css'
Projects for 'delphi'
Projects for 'design'
Projects for 'drupal'
Projects for 'excel'
Projects for 'facebook'
Projects for 'flash'
Projects for 'html'
Projects for 'java'
Projects for 'javascript'
Projects for 'joomla'
Projects for 'iphone'
Projects for 'mysql'
Projects for 'photoshop'
Projects for 'php'
Projects for 'python'
Projects for 'ruby'
Projects for 'seo'
Projects for 'sql'
Projects for 'sysadm'
Projects for 'translate'
Projects for 'typing'
Projects for 'twitter'
Projects for 'vbnet'
Projects for 'xml'
Projects for 'wordpress'
Projects for 'writing'
Read RSS feeds ... New!
RSS feed for 'android'
RSS feed for 'ajax'
RSS feed for 'asp'
RSS feed for 'aspnet'
RSS feed for 'cms'
RSS feed for 'cpp'
RSS feed for 'csharp'
RSS feed for 'css'
RSS feed for 'delphi'
RSS feed for 'design'
RSS feed for 'drupal'
RSS feed for 'excel'
RSS feed for 'facebook'
RSS feed for 'flash'
RSS feed for 'html'
RSS feed for 'java'
RSS feed for 'javascript'
RSS feed for 'joomla'
RSS feed for 'iphone'
RSS feed for 'mysql'
RSS feed for 'photoshop'
RSS feed for 'php'
RSS feed for 'python'
RSS feed for 'ruby'
RSS feed for 'seo'
RSS feed for 'sql'
RSS feed for 'sysadm'
RSS feed for 'translate'
RSS feed for 'typing'
RSS feed for 'twitter'
RSS feed for 'vbnet'
RSS feed for 'xml'
RSS feed for 'wordpress'
RSS feed for 'writing'
New!
Проекты на русском
(Projects in Russian)

Short URL:
1001fp.com
Mobile version:
m.1001freelanceprojects.com
Copyright © 2005-2022 1001 Freelance Projects