math

Recursion Question in Python. No Conditionals or Loops

Recursion Question in Python. No Conditionals or Loops Question: I am trying to figure out how to print the word "hello" 121 times in python. I need to use a function without conditionals or loops, no new lines, and no multiplying the string by an integer. I thinking something like: print_hello(): print(‘hello’) print_hello() print_hello() but …

Total answers: 12

Calculate angle from slope in inverted Y axis

Calculate angle from slope in inverted Y axis Question: I currently have a series of lines drawn in a football pitch, each one formed by an X and Y point. These lines are the passes of a player and I want to see if it is a backward pass, forward pass, lateral pass depending on …

Total answers: 1

Curve translation in Python does not reach expected value

Curve translation in Python does not reach expected value Question: Suppose I have two curves, f(x) and g(x), and I want to evaluate if g(x) is a translation of f(x). I used Sympy Curve to do the job with the function translate. However, I need help to reach the correct result. Consider the two functions: …

Total answers: 2

How to take a whole matrix as a input in Python?

How to take a whole matrix as a input in Python? Question: I want to take a whole matrix as an input in Python and store it in a dataframe. Pandas can do it automatically with read_csv function but it requires a CSV file. I want to input/copy-paste a matrix directly at the input, without …

Total answers: 1

Increasing recursion fails with: Process finished with exit code -1073741571 (0xC00000FD)

Increasing recursion fails with: Process finished with exit code -1073741571 (0xC00000FD) Question: import sys sys.setrecursionlimit(1000000000) def F(n): if n == 1: return 1 if n > 1: return n * F(n – 1) print(F(2023)/F(2020)) When the recursion is increased with setrecursionlimit, the following error is returned. Process finished with exit code -1073741571 (0xC00000FD) But without …

Total answers: 1

scipy.integrate.quad with non plausible values

scipy.integrate.quad with non plausible values Question: He guys, I’m al little bit in trouble with math. So there is an old question and it’s not really solved. I thought about editing the old one, but I think it’s even good to start a new question. As you can see below there is an example of …

Total answers: 1

Resize images while preserving aspect ratio

Resize images while preserving aspect ratio Question: I have a small problem that could have a simple solution, but unfortunately I’m not very good at math. I have three images that need to be stacked on top of each other and their heights add up to more than the screen height. So to fix, I …

Total answers: 1

LeetCode Climbing Stairs

LeetCode Climbing Stairs Question: I tried to separate the climbing scenarios into scenarios of how many 2 steps can be taken and to solve the question according to the sum of the combinations of the moments where 2 steps can be taken in these scenarios. import math class Solution: def climbStairs(self, n: int) -> int: …

Total answers: 1

Fibonacci Sequence based question slightly changed

Fibonacci Sequence based question slightly changed Question: I was recently given this question in one of my interview which I ofcourse, failed. I just want to know how this will be solved. The code I tried to use was this: def gibonacci(n, x, y): # Base case if n == 0: return x elif n …

Total answers: 2