@steven.daprano has way better skills than I, as you’ll see from all the responses he’s posted.
I consider myself a ‘beginner’ having no more than a couple of years experience using Python (three, at best) and it’s only really over the past year or so that I’ve been able to start and get deeper into it (for reasons that I’ll not go in to).
I’ll continue to follow this thread as I’m sure that I’ll learn something new from Steven as I often times do: in fact assert is new to me, so case in point.
N = int(input('enter the upper limit: '))
p = int(input('enter a no : '))
while p <= N:
for n in range(1, p):
q = 4
r = 5
m = 2
if (p <= 2) or (p > q > r):
print(" INVALID NUMBER ")
'''N = int(input('enter the upper limit: '))
p = int(input('enter a no : '))
while p <= N:
for n in range(1, p):
q = 4
r = 5
m = 2
if (p <= 2) or (p > q > r):
print(" INVALID NUMBER ")
elif(p % 2 != 0):
q = int((p*p-1)/2)
r = int((p*p+1)/2)
else:
q = int((p/2)**2 - 1)
r = int((p/2)**2 + 1)
assert p**2 + q**2 == r**2
print((p,q,r))
print((p*m,q*m,r*m))
p = p + 1
m = m + 1
'''
So, three backtic (no space) then the word python again no space then hit the return key, then your code, then another return key press and finish with three more backtics. If you want anything else after the code block, leave a blank line between the final three backtics and the rest of your post.
def eval(exp):
A=input(exp)
n= float(input('Enter the number of years: '))
r= float(input('Enter the rate of interest: '))
p= float(input('Enter the principal amount: '))
def calculate(n,r,p,exp):
for i in range(1,len(exp),2):
opr=exp[i]
opd=exp[i+1]
if (opr == '+'):
A += value(opd)
elif (opr == '-'):
A -= int(value(opd))
elif (opr == '*'):
A *= int(value(opd))
elif (opr == '/'):
A /= int(value(opd))
elif (opr == '%'):
A %= int(value(opd))
elif (opr == '**'):
A **= int(value(opd))
else:
return -1
return A