Repetition in the output

No worries, thanks.

@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.

Thank you Rob you are very kind :slight_smile:

If you want to learn more about assert, you can read this:

https://import-that.dreamwidth.org/676.html

1 Like

Thank you for your kind comment.

Yes. I’m always open to learning more, as I want to level-up my Python skills; my main reason for getting involved with this Forum.

Thank you for the link: I will study the contents and take notes.

Have a good weekend.

Peace.

2 sides are active now.(Rob & Steven)…forgot center point(it’s me…my coding)

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((pp-1)/2)
r = int((p
p+1)/2)

else:
q = int((p/2)**2 - 1)
r = int((p/2)**2 + 1)

assert p2 + q2 == r**2
print((p,q,r))
print((pm,qm,r*m))
p = p + 1
m = m + 1

tried something something…help me guys

I’ll take a look ASAP.

Just one more thing about posting code (if you recall I said that backtics are used in markdown, as code tags. So, for Python:

```python
your code goes here
```

That will make for an easier experience for others.

As a side note: I have posted a feature request in the Feedback section that’s related. I hope that it’ll be acted upon as and when.

oh u meant triple quotes…kkk

For code blocks, yes: backtics, not quotes.

You can also use a single backtic for in-line keywords or a very short line of code, so as to highlight said: print("markdown is fab!")

1 Like
'''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
        '''

Is this correct Rob?

It’s closer and I can see that you’re trying.

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.

screenshot pl…am not able to follow that :cold_sweat:

Screenshots are BAD, of reasons that are off topic here.

Don’t sweat it; you’re close enough for now: you’ll get the hang of it.

I use a very nice app for my notes and it uses Markdown, so I find Markdown second nature now.

I need to sleep, so I’ll AFK for a few hours,but I’ll be back.

Have a good day.

ok take rest and come back…I will go through it

Please practice in the Discuss sandbox and read the Quick Start Guide.

So much of homework…before coding Steven…ok I will give a try :disappointed_relieved:


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

Hi Steven,

Is this correct? :cold_sweat:

1 Like