Python Forum
Python 2.7 - Help-me please!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 2.7 - Help-me please!
#1
Guys, I'm studying python and if someone can help me solve these algorithms in python version 2.7, I will be grateful. Thank you!

Question 1:

Make a Python program that shows the following N Series terms:

S = 1/1 + 2/3 + 3/5 + 4/7 + ..... + N / M

In addition, print the sum of the series elements as well.

Ex: N = 3

S = 1 + 2/3 + 3/5

Sum = 2.266666

------------------------------

Make a program that reads a set of N values ​​and prints the triangular numbers, if any, TELL how many of those values ​​are triangular.

A number is triangular when it is the product of 3 consecutive integers.

Ex: 120 = 4 * 5 * 6


Make it as simple as possible, just using the basic instructions, please, you cannot use a list, etc.
Reply
#2
why learning 2.7. It life ended January 1st. Learn python3

That said, we are glad to help but we are not going to write it for you.
Show what have you tried. Post your code in python tags. If you get any error - post full traceback, in error tags. Ask specific questions.
https://python-forum.io/misc.php?action=help&hid=52
See BBcode help for more info.
ndc85430 likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Buran, I'm in college and this is the version that they demanded. I managed to create the first code and I would like to know if the logic is correct, below:


N1 = input("Type N: ")

for fo in range(1,N1+1):
    if fo == 1:
        ResultAdd = 1
        print fo,"/",fo
    else:
        N1 = fo
        N2 = (fo*2) - 1
        ResultAdd += N1/float(N2)
        print N1,"/",N2

print "Result of elements: ",ResultAdd
As for the second code, I can't really develop logic, could you help me? Create the code so I can better understand the logic? It is for the purpose of studies, I would like to see the algorithm to understand it better, I hope you understand.
buran write Oct-22-2020, 03:32 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#4
Change colleges to one that is up to date.
Jeffrey Summers
Professor and Chair Department of Internal Medicine
East Tennessee State University
buran and Gribouillis like this post
Reply


Forum Jump:

User Panel Messages

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