Python Forum

Full Version: Python 2.7 - Help-me please!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
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.
Change colleges to one that is up to date.
Jeffrey Summers
Professor and Chair Department of Internal Medicine
East Tennessee State University