The German mathematician Gottfried Leibniz developed the following method to approximate the value of r: T/4 = 1 - 1/3 + 1/5 - 1/7 + ... Write a program that allows the user to specify the number of iterations used in this approximation and that displays the resulting value.
Q: What does the function shown below do? def add digits(num): total = 0 while num > 0: total += num %…
A: As per our guidelines we are supposed to answer only one question kindly repost other question as a…
Q: You will write a program that will calculate the area of a square based on a randomly generated…
A: I give the code along with output and code screenshot in Python
Q: 1 original_total = "5.45" 2 donation = "e.55" 3 4 #You may modify the lines of code above, but don't…
A: Given data, Write some code that will print the customer's total and how much they donated. This…
Q: Write an algorithm to Form a two way list by one way Header list which is given below. ALG +14
A: Algorithm :- To create two way list by one way Header list in Python :- Step1 : - Create the new…
Q: Write a program continuously asks the user to enter a sentence until they type "-999".
A: The following is the required python program #the function definition for uppercasedef…
Q: The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of…
A: Program Plan: Create a data frame and prompt for the purchase price. Evaluate the starting balance…
Q: C. Assume that we execute the following assignment statements: width = 17 height = 12.0 delimiter =…
A: This question comes from Python Programming which is a part of computer science. Let's discuss it in…
Q: You have a list of elements and their prices. Select your preferred lists from the item based on…
A: According to the information given:-we have to follow the instruction to get the desired outcome.
Q: Write a function that uses print statements to draw the box below. Then write a function called…
A: Solution :: Let's see first what is python programming ? Answer :: Python is an…
Q: Write a function (including docstring) called multiply_term that takes a polynomial as inputs and a…
A: We know, to add two polynomials, we add/subtract the coefficients corresponding to like terms, i.e…
Q: Please use Pytho
A: Coded using Python 3.
Q: The vase shown below can be described as a cylinder with a varying radius. Using a y-coordinate…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: SE PYTHON THANK YOU
A: Coded using Python 3.
Q: Write a program that allows the user to navigate the lines of text in a file. The program should…
A: Logic to proceed Reading the given file by user input. The text read from the file will contain…
Q: Create a two dimensional array that can store below values in same rows and columns. Get value from…
A: The required Python code for given problem is: n=int(input("Enter the value of n: ")) # read…
Q: Write a program that will ask for a number continuously until the user enters 'X'. The program must…
A: Given: To write a python code.
Q: category subject message 16150 politics,National Crime Survey,"Well, I droppe... NaN NaN 256…
A: To drop all the rows with the NaN values, you may use : DataFrame.dropna(axis=0, how='any',…
Q: ΡΥTHOΝ Problem 5: Hash tables Using the following hash function: hash = lambda x: sum (1 for c in x…
A: hash = lambda x: sum(1 for c in x if c.isupper()) %5 -> By using the hash function, you can…
Q: The greatest common divisor of two positive integers, A and B, is the largest number that can be…
A: # Defining the function to calculate the GCDdef EuclideanGCD(A,B): if A < B: A , B…
Q: Write code that raises an appropriate error if the value of the data variable is between 1 and 10.
A: Code: data = int(input("Enter a number:"))if data >=0 and data<=10:#condition checking if the…
Q: The 141 cipher of an input string of letters changes the letters whose index is even (note: zero is…
A: I will provide you a commented code, So just read the code once and you will easily understand it.
Q: 1. Using a linked list store different courses and their prerequisites in chain and based on the…
A: code:-- # course list course=['PF','OOP','Dst','DBMA','OOAD','AI','DP']# taking user input…
Q: 3. Suppose you have the following matrices: 1 2 1 2 3 4 4 5 7 8 10 11 12, M1= and M2 = 5 6 7 8 9.…
A: Since the input matrices are already given we can include them in program.
Q: PrimeOnString (P, I) is a decision procedure that returns 'yes' if P(I) is a string encoding of a…
A: Code: def PrimeOnString(P): for i in range(2, P): if n%i==0: return 1…
Q: The quadrant in which a line drawn from the origin resides is determined by the angle the line makes…
A: print("Enter angle : ")angle = int(input()) if angle % 90 == 0: print("On Axis")elif angle > 0…
use python
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- java-matlabLets say we are creating a python game. A word is displayed gets displayed on the screen. The players of the game must type as many words as they an that are related to the word that is displayed. If players type in the same word multiple times, it is ignored. One the players are done taking turns, the program gives each player a score that is based off how many wrods they entered that are similiar to what other words players have entered. So for a player to get a point, the word they typed must be typed by another student. QUESTION: We need to store the words typed by the players and all words etered. Would we use a list, set, dict or tuple?In python, Problem Description:Sheldon and Leonard are physicists who are fixated on the BIG BANG theory. In order to exchange secret insights they have devised a code that encodes UPPERCASE words by shifting their letters forward. Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes this makes us go past Z, the last letter of the alphabet. Whenever this happens we wrap around, treating A as the letter that follows Z. For example, shifting Z by S = 2 positions gives B. Sheldon and Leonard’s code depends on a parameter K and also varies depending on the position of each letter in the word. For the letter at position P, they use the shift value of S = 3P + K. For example, here is how ZOOM is encoded when K = 3. The first letter Z has a shift valueof S = 3 × 1 + 3 = 6; it wraps around and becomes the letter F. The second letter, O, hasS = 3 × 2 + 3 = 9 and becomes X. The last two letters…
- mplement a Java program that applies the Newton-Raphson's method xn+1 = xn – f(xn) / f '(xn) to search the roots for this polynomial function ax6 – bx5 + cx4 – dx3+ ex2 – fx + g = 0. Fill out a, b, c, d, e, f, and g using the first 7 digits of your ID, respectively. For example, if ID is 4759284, the polynomial function would be 4x6 – 7x5 + 5x4 – 9x3+ 2x2 – 8x + 4 = 0. The program terminates when the difference between the new solution and the previous one is smaller than 0.00001 within 2000 iterations. Otherwise, it shows Not Found as the final solution.The Fibonacci algorithm is a famous mathematical function that allows us to create a sequence of numbers by adding together the two previous values. For example, we have the sequence:1, 1, 2, 3, 5, 8, 13, 21…Write your own recursive code to calculate the nth term in the sequence. You should accept a positive integer as an input, and output the nth term of the sequence.Once you have created your code, add comments describing how the code works, and the complexity of any code you have created.(Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.
- A recursive function is a function defined in terms of itself via self-referential expressions. This means that the function will continue to call itself and repeat its behavior until some condition is met to return a result. Write a complete python program that includes a recursive python method, sumThem which accepts an argument, n, sums all the odd, or all the even, positive integers up to n*3, depending on whether n*3 is odd or even. The number should be entered by the user You should include in your answer a screenshot that shows the program and the output for the value n*3 where n must be equal your last ID digit. For example, if your ID is 201314151617, then 7 will be entered, and the calculations should be applied to 21. Expected Output Sample: Enter the number: 0 The sum of even numbers up to 0 will be: 0Your first task will be to write a simple movement simulator on a snakes and ladders board. For this questionyou can ignore the snakes and ladders and just simply assume you only have to deal with moving. You willneed to simulate rolling the die - this can be done by using the Python random module and the randint method.Your function play_game will take as input the length of the board (an integer), "play" the game by rolling the diemultiple times until the sum of rolls is larger or equal to the length of the board. (note: this is one of the possibleand simplest end rules). The function should return the total number of rolls required to finish the the particulargame that was played. Obviously this number will vary as it depends on the specific random rolls performedduring the movement simulation.In-Class Exercise 6 A set of linear equations is given: 10 x₁ + 4x₂ - 2x3 = 26 4x₁ - 8x₂ + x3 = 0 2 2x₁ + x₂ - 5x3 = 40 4 1) Solve the equations by using Gauss-Seidel iterative method. Do it "by hand" (you can use matlab for arithmetic calculations). Start with guessing answer [X1 X2 X3] = [0 0 0] and try at least three iterations. 2) Use power method to find the smallest eigenvalue of the coefficient matrix. (hint: use inverse of coefficient matrix, then apply power method to find largest eigenvalue. Take inverse of that eigenvalue) 3) Find all eigenvalues and their corresponding eigen vectors of the coefficient matrix.
- Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia Partially done code (C++): #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) {vector<string> nameList;vector<string> permList;string name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method.return 0;}Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia partial code below, only lines 9-11, and 18 can be added onto, the rest must stay the same. #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) { vector<string> nameList; vector<string> permList; string name; // TODO: Read in a list of names; stop…Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia main.cpp #include <vector>#include <string>#include <iostream> using namespace std; // TODO: Write method to create and output all permutations of the list of names.void AllPermutations(const vector<string> &permList, const vector<string> &nameList) { } int main(int argc, char* argv[]) {vector<string> nameList;vector<string> permList;string name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method.return 0;}