in my i.t lesson we were intoduced to 'raspberry pi' within 'Python' and for my homework i have to explain what we did in the lesson. It says i have to include what 'input' is when coding a programme. Please help and reply as soon as possible and keep in mind i dont really understand computer or technology language/words! Plus, i remember watching my teacher show us on the board something along the lines of "end/run command/programme when enter is clicked" can anyone help me with that? Thanks!! |
+0 forum
1 | ||

Hi Everyone, For a couple weeks, I have been developing a pi approximation program and making little upgrades. Right now, the program asks for an input of iterations and then prints out the approximation. Now, I want to have every iteration printed out into an excel file with an approximation accurate to .000001 [50,000 iterations] However, I realized that the current setup of my program does not work well, so I think some rework is in order. So my goal is to eliminate the input process; and instead, base the iterations on accuracy, not input. That is what I would … |
+0 forum
2 | ||

We estimate pi. We assume as in Figure 10 is a side of the square. The first type, which defines a function IsInCircle Quadrant is the point or not. intIsInCircle (floatx, floaty); The number of random points that are inside the square, the Number of points within the quadrant to the total number of points in your account. This ratio is equal to one-fourth of pi. Find a way to write the function to determine the number of Must be at least several hundred random locations to get an error. IntFind (); … |
+0 forum
7 | ||

Tadaa! This is my first attempt at writing in Python, trying to solve a good question posed [here](http://www.daniweb.com/software-development/python/threads/32007/projects-for-the-beginner/17#post2016892) #----------------------------------------------------------------------------------------------- # # Python 2.7 # # Calculating area and radius of polygons with known number of sides and the length of this side # Adapted formulas used from this site: http://www.mathwords.com/a/area_regular_polygon.htm # DM 17/09/2013 first attempt to produce a plusminus decent Python script #----------------------------------------------------------------------------------------------- import math from string import Template def Calculate_PolygonArea (NumberofSides, SideLength ): return ( NumberofSides * SideLength ** 2 ) / (4 * math.tan( math.pi / NumberofSides )) def Calculate_PolygonRadius( NumberofSides, SideLength ): return SideLength / (2 * … |
+1 forum
7 | ||

The news wires have been buzzing over the weekend after it emerged that the Raspberry Pi website had been hit by a 'million zombie' Distributed Denial of Service (DDoS) attack during the week. Although the outage was relatively brief, with the Raspberry Pi Foundation admitting the attack with a Twitter message that stated "We're being DDoS'd at the moment—very sorry if you can't see the website" and continued "If it goes on, we'll try to get some more capacity in tomorrow". The attack meant that parts of the site were offline for e a few hours while others were very … |
+1 forum
1 | ||

Write a function estimatePi() to estimate and return the value of Pi based on the formula found by an Indian Mathematician Srinivasa Ramanujan. It should use a while loop to compute the terms of the summation until the last term is smaller than 1e-15. The formula for estimating Pi is given below: As per Ramanujam's estimation (I'm sorry, I'm unable to upload the image) def estimatePi(): import math def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) k=0 final=0 pi=0 while pi<1e-15: a=factorial(4*k) b=(1103+26390*k) c=factorial(k) d=c**4 e=396**(4*k) f=2*math.sqrt(2)/9801 final+=(a*b*f)/(d*e) k+=1 pi=1/final return pi and, my problem … |
+0 forum
2 | ||

I have to wirte a code for monte carlo pi approximation for a menu driven calculator. here is my code but when i run it it shows me 1 instead of the pi value. can someone tel me what is wrong. double approximatepi(void) { double x,y,z,pi,randomnumber; double r,p,in; int tries; srand(0); while (tries!=p) {randomnumber=((double)rand())/((double)RAND_MAX)*2*r; x=randomnumber; y=randomnumber; z=r*r; pi=(((double)in/(double)p))*4; if (z>=x*x+y*y) {in++; } } return pi; } |
+0 forum
2 | ||

hi, I already know how to use setprecision but the function wont let the round go up past 16. [CODE]#include<iostream> #include<stdio.h> #include<math.h> #include<iomanip> using namespace std; int main () { double pi = 3.14159265358979323846264338327950288419716939937510; cout << setprecision(50) << pi << endl; system("pause"); } [/CODE] the output is just 3.1415926535897931 the code to force it to go past 16 would be something like this: [CODE]#include<iostream> #include<stdio.h> #include<math.h> #include<iomanip> using namespace std; int main () { double pi = 3.14159265358979323846264338327950288419716939937510; cout << force_max_digits_setprecision(50) << pi << endl; //I just added "force_max_digits_" system("pause"); } [/CODE] any solutions? Thanks. |
+0 forum
4 | ||

The homework question said to rearrange statements and remove part of code that made it calculate incorrectly. I'm lost on this and have been searching multiple places and trying different things. This is a beginning C++ class, too, so, for homework in the first half I can't very well be going into complicated strings of advanced coding and pretend I'm that great when I can't even do this. I'd mostly appreciate hints and nudges toward understanding it, but straight answers suffice, too. [CODE]#include <iostream> #include <iomanip> using namespace std; int main () { double pi = 0; long i; double … |
+0 forum
7 | ||

Code Snippet
Generating Pi decimals revisited Little clean up of vegaseat's code for generating pi decimals. Added number of decimals desired and string type return for easy use with ''.join() |
+1 forum
4 | ||

Ok so i want to make a program that calculates pi. Ive done that already but it only gives me so many decimal places. I want it to give me tons. Im using Dev C++ if that helps too. Here's my code: [CODE] #include <iostream.h> #include <math.h> int main() { double pi = 0; int elements; cout << "How many???"; cin >> elements; for (int n = 1; n <= elements; n++) { pi += (double) pow(-1, n+1)/(2*n-1); } pi *= 4; cout << "Estimated PI value (" << elements << " elements): " << pi; system("pause"); return 0; } … |
+0 forum
27 | ||

Your task is to write a main program which asks the user for an error value and then calls a function CalculatePi (error) which returns an approximate value of π. The function CalculatePi should use a loop to calculate the above series (*). It should keep two values, currentApproximation and nextApproximation. Initially currentApproximation = 4. The loop should keep adding and subtracting terms until the difference between currentApproximation and nextApproximation is less than error. It should then return currentApproximation. |
-6 forum
1 | ||

Im new to c++ and this is our first assignment. I dont even know where to start. Help! Your task is to write a main program which asks the user for an error value and then calls a function CalculatePi (error) which returns an approximate value of π. The function CalculatePi should use a loop to calculate the above series (*). It should keep two values, currentApproximation and nextApproximation. Initially currentApproximation = 4. The loop should keep adding and subtracting terms until the difference between currentApproximation and nextApproximation is less than error. It should then return currentApproximation. |
-1 forum
1 | ||

Hey, I'm a student, doing VB at college. I've been trying to make a program to compute Pi, and am making good progress, I think I know what to do. However, part of the algorithm requires me to cube a number. The way I'm doing it is having stored the number in an array, with each cell in the array 1 digit. I've made sub procedures to add/subtract 2 arrays, and multiply/divide an array by a number. This code multiplies mul1() by a single number mul2 [CODE]Sub mul(ByRef mul1() As Byte, ByRef mul2 As Byte) Dim hold, carry, temp(digits + … |
+0 forum
1 | ||

i need some help on my pi approximation it's really slow. compile it and see for your self. i think my problem is with my math. it comes out with the wrong first few numbers. i'm trying to use gregory's formula or the advanced version of it.[CODE]#include <iostream> #include <conio.h> using namespace std; void main() { long double ans=4,l=1; cout<<ans<<endl; for(int i=1;i<=100000000;i++) { l++; if(i % 2 == 1) { ans=(ans-1/(2*l +1)); } if(i % 2 == 0) { ans=(ans+1/(2*l+1)); } system("cls"); cout<< ans <<endl; } _getch(); }[/CODE] |
+0 forum
1 | ||

Hi, I am trying to build a simple calculator to get x^y, I have found that the '^' symbol is not used in C# and I have to use 'Math.Pow' instead. I have a form with 2 text boxes for input, an rtf box for output and a button for activating the function. Here is my button function code:- [code=c] void Button1Click(object sender, EventArgs e) { string text1 = Box1.Text; string text2 = Box2.Text; int num1 = int.Parse(text1); int num2 = int.Parse(text2); Output.Text = Convert.ToString(System.Math.Pow(Convert.ToDouble(num1), Convert.ToDouble(num2))); } [/code] It all works fine but what I really need is to be … |
+0 forum
4 | ||

Code Snippet
PI generator (update) This is an update of an earlier version. In this version the string containing the approximated pi value is created directly from the iteration of the generator. This way the program is simplified and can be used with Python2 and Python3 ... |
+1 forum
0 |

The End.