Python Forum
Python 2.7 - Help-me please! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Python 2.7 - Help-me please! (/thread-30482.html)



Python 2.7 - Help-me please! - dansup - Oct-22-2020

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.


RE: Python 2.7 - Help-me please! - buran - Oct-22-2020

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.


RE: Python 2.7 - Help-me please! - dansup - Oct-22-2020

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.


RE: Python 2.7 - Help-me please! - jefsummers - Oct-23-2020

Change colleges to one that is up to date.
Jeffrey Summers
Professor and Chair Department of Internal Medicine
East Tennessee State University