Python Forum
Help solving an exercise?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help solving an exercise?
#1
Sad 
hey all,
I'm struggling in solving an exercise of my python introduction course. I leave the problem in the attachments. I'm really at the beginning of my coding skills journey so every help will be welcomed
   
Reply
#2
I may as well get this out of the way.

So what have you tried? You aren't going to get any help unless you first demonstrate that you tried to solve the problem.

Your question is too open ended. What kind of help your you looking for? Do you understand the assignment? Do you have a specific Python question?
Reply
#3
(Apr-16-2023, 07:01 PM)deanhystad Wrote: I may as well get this out of the way.

So what have you tried? You aren't going to get any help unless you first demonstrate that you tried to solve the problem.

Your question is too open ended. What kind of help your you looking for? Do you understand the assignment? Do you have a specific Python question?

As I understood the exercise, I tried to simplify the integration function of problem 3 under the conditions of problem 2, but I'm not sure this is the correct procedure.
in a first step I've defined the integrated function of problem 2 and also defined the conditions for the interval (following the conditions of problem 2). I used a loop to define it. But I'm not sure it's the right way to solve it since my solution doesn't really take into account N and I don't know how to implement it into the original function.
see my solution in the attachment. running it with the given factors prints a solution of 10

Attached Files

Thumbnail(s)
   
Reply
#4
Please post your code (with python tags) instead of screen shots.

You aren't doing the summing part. for k starting at 1 and ending at N-1 you need to compute f(a + k / M * (b - a)) and add all the values together. This will require a loop, or something that acts like a loop.
sumnation = 0
for k in range(1, N-1):
    sumnation += function(k)
I think you also need to review your function. What you wrote does not look like
A * x**n if x >= 1 else A * x**(-n)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020