math

How do you calculate the amount of prime numbers less than or equal to N?

How do you calculate the amount of prime numbers less than or equal to N? Question: I want to write a program that determines the amount of prime numbers less than or equal to N (variable containing user input). This is what I’ve got: N = int(input("Enter number: ")) count = 0 primes = [] …

Total answers: 3

Variable returns empty even when assigned by dictionary – Python

Variable returns empty even when assigned by dictionary – Python Question: When crying to convert an RGB value to Hex using dictionaries one variable returns correctly as the Key turned to the Hex value but when tried with a second variable it returns as None. capitalization doesnt seem to be the problem. def rgb(r, g, …

Total answers: 2

Parametric curve is always in front of Surface

Parametric curve is always in front of Surface Question: I am trying to build an animation of a Dehn twist in a torus in Manim. My goal is to get something that looks like this: I managed to parametrize the curve and surface correctly in Manim. As you can see, the portion of the parametric …

Total answers: 2

Float division issue in Python (tkinter)

Float division issue in Python (tkinter) Question: I’m working on a program which uses inputs from a tkinter interface to calculate the relative funniness of a joke based on sciencewritenow.com’s formula: H ≥ ((((T1 + T2) / (T3 – R)) × I ) / D = ((T3 / T4) × S)) × B While I …

Total answers: 1

Octal to Decimal conversion of number

Octal to Decimal conversion of number Question: I want to convert an octal number into a decimal one. Why am I getting 6 as an output instead of 83? import math def octalToDecimal(octalNumber): decimalNumber = 0 i = 0 while (math.floor(octalNumber) != 0): rem = math.floor(octalNumber) % 10 octalNumber /= 10 decimalNumber += rem * …

Total answers: 1

How to plot multiple periods using pyplot?

How to plot multiple periods using pyplot? Question: everyone! I’m learning about signals now, but I’m having a tough time trying to plot more than one period using pyplot. I don’t know if the problem is with the mathematical part or with the code itself. I think this is a silly question, but any help …

Total answers: 1

numpy e^i(theta) and trigonometric cos(theta) + isin(theta) does not match

numpy e^i(theta) and trigonometric cos(theta) + isin(theta) does not match Question: I read, So I tried to do apply this to a list of points as shown below And below part works perfectly as expected. Zj = np.array([1. +0.j , 0.5+0.5j, 0. +0.j , 0.5-0.5j, 1. +0.j ]) δj = Zj[1: ] – Zj[:-1] assert(np.allclose(δj, …

Total answers: 2