python 3 TypeError: '>' not supported between instances of 'int' and 'str' in an if statment











up vote
0
down vote

favorite












Q_1 = input ('Name the organelles where protiens are synthesised? : ')
if Q_1 == 'ribosome':
print ('correct')
score = score + 1
else:
print ('WRONG')

Q_2 = input ('Suggest why plant cells have a cell wall and animal cells don't ?: ')
if Q_2 == 'To control the flow of water and oxygen':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_3 = input ('True or false is bacteria an examples of a prokaryotic cell ?: ')
if Q_3 == 'true':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_4 = input ('True or false prokaryotes don't have a cell wall ?: ')
if Q_4 == 'true':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_5= input ('What is a stem cell?: ')
if Q_5 == 'An undifined cell':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_6 = input ('True or false there are embryonic stem cells?: ')
if Q_6 == 'true':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_7 = input ('What is diffusion?: ')
if Q_7 == 'The movment of gas particles from an area of high concentraction to low concentration':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_8 = input ('True or false having a greater surface area increase the rate of diffusion?: ')
if Q_8 == 'true':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1

Q_9 = input ('Define osmosis ?: ')
if Q_9 == 'The movment of water particles from an area of high to low concentration':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1


Q_10 = input ('True or false increasing temperature increases the rate of osmosis?: ')

if Q_10 == 'true':
print ('correct')
score = score + 1

else:
print ('WRONG')
score = score -1
int_score = int(score)

if int_score >'0':
score = 0
print (score)


This is a GCSE bio quiz I'm working on.
I want to set the score to 0 if it goes into negative numbers.










share|improve this question




























    up vote
    0
    down vote

    favorite












    Q_1 = input ('Name the organelles where protiens are synthesised? : ')
    if Q_1 == 'ribosome':
    print ('correct')
    score = score + 1
    else:
    print ('WRONG')

    Q_2 = input ('Suggest why plant cells have a cell wall and animal cells don't ?: ')
    if Q_2 == 'To control the flow of water and oxygen':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_3 = input ('True or false is bacteria an examples of a prokaryotic cell ?: ')
    if Q_3 == 'true':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_4 = input ('True or false prokaryotes don't have a cell wall ?: ')
    if Q_4 == 'true':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_5= input ('What is a stem cell?: ')
    if Q_5 == 'An undifined cell':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_6 = input ('True or false there are embryonic stem cells?: ')
    if Q_6 == 'true':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_7 = input ('What is diffusion?: ')
    if Q_7 == 'The movment of gas particles from an area of high concentraction to low concentration':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_8 = input ('True or false having a greater surface area increase the rate of diffusion?: ')
    if Q_8 == 'true':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1

    Q_9 = input ('Define osmosis ?: ')
    if Q_9 == 'The movment of water particles from an area of high to low concentration':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1


    Q_10 = input ('True or false increasing temperature increases the rate of osmosis?: ')

    if Q_10 == 'true':
    print ('correct')
    score = score + 1

    else:
    print ('WRONG')
    score = score -1
    int_score = int(score)

    if int_score >'0':
    score = 0
    print (score)


    This is a GCSE bio quiz I'm working on.
    I want to set the score to 0 if it goes into negative numbers.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Q_1 = input ('Name the organelles where protiens are synthesised? : ')
      if Q_1 == 'ribosome':
      print ('correct')
      score = score + 1
      else:
      print ('WRONG')

      Q_2 = input ('Suggest why plant cells have a cell wall and animal cells don't ?: ')
      if Q_2 == 'To control the flow of water and oxygen':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_3 = input ('True or false is bacteria an examples of a prokaryotic cell ?: ')
      if Q_3 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_4 = input ('True or false prokaryotes don't have a cell wall ?: ')
      if Q_4 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_5= input ('What is a stem cell?: ')
      if Q_5 == 'An undifined cell':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_6 = input ('True or false there are embryonic stem cells?: ')
      if Q_6 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_7 = input ('What is diffusion?: ')
      if Q_7 == 'The movment of gas particles from an area of high concentraction to low concentration':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_8 = input ('True or false having a greater surface area increase the rate of diffusion?: ')
      if Q_8 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_9 = input ('Define osmosis ?: ')
      if Q_9 == 'The movment of water particles from an area of high to low concentration':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1


      Q_10 = input ('True or false increasing temperature increases the rate of osmosis?: ')

      if Q_10 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1
      int_score = int(score)

      if int_score >'0':
      score = 0
      print (score)


      This is a GCSE bio quiz I'm working on.
      I want to set the score to 0 if it goes into negative numbers.










      share|improve this question















      Q_1 = input ('Name the organelles where protiens are synthesised? : ')
      if Q_1 == 'ribosome':
      print ('correct')
      score = score + 1
      else:
      print ('WRONG')

      Q_2 = input ('Suggest why plant cells have a cell wall and animal cells don't ?: ')
      if Q_2 == 'To control the flow of water and oxygen':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_3 = input ('True or false is bacteria an examples of a prokaryotic cell ?: ')
      if Q_3 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_4 = input ('True or false prokaryotes don't have a cell wall ?: ')
      if Q_4 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_5= input ('What is a stem cell?: ')
      if Q_5 == 'An undifined cell':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_6 = input ('True or false there are embryonic stem cells?: ')
      if Q_6 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_7 = input ('What is diffusion?: ')
      if Q_7 == 'The movment of gas particles from an area of high concentraction to low concentration':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_8 = input ('True or false having a greater surface area increase the rate of diffusion?: ')
      if Q_8 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1

      Q_9 = input ('Define osmosis ?: ')
      if Q_9 == 'The movment of water particles from an area of high to low concentration':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1


      Q_10 = input ('True or false increasing temperature increases the rate of osmosis?: ')

      if Q_10 == 'true':
      print ('correct')
      score = score + 1

      else:
      print ('WRONG')
      score = score -1
      int_score = int(score)

      if int_score >'0':
      score = 0
      print (score)


      This is a GCSE bio quiz I'm working on.
      I want to set the score to 0 if it goes into negative numbers.







      python python-3.x syntax-error






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 14:09









      molbdnilo

      39.9k32152




      39.9k32152










      asked Nov 11 at 14:02









      Zakariya Islam

      14




      14
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          From what I can see, the variable int_score suggests it holds an integer and in your if statement you write:



          if int_score < '0':
          ...


          In this case, 0 is a string. You need to write it as an int so that it can be compared:



          if int_score < 0:
          ...


          As a side note, might I suggest that your algorithm for checking correct answers is not optimal as you have to input the exact answer to get it right. You may want to check for keywords like so:



          Suppose the answer is photosynthesis produces glucose and oxygen, checking for ‘glucose’ and ‘oxygen’:



          ans = input('what are the products of photosynthesis')
          words = ans.split()
          if all(word in words for word in ('glucose', 'oxygen')):
          print('correct!')
          score += 1
          else:
          print('wrong!')





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249507%2fpython-3-typeerror-not-supported-between-instances-of-int-and-str-in-an%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            From what I can see, the variable int_score suggests it holds an integer and in your if statement you write:



            if int_score < '0':
            ...


            In this case, 0 is a string. You need to write it as an int so that it can be compared:



            if int_score < 0:
            ...


            As a side note, might I suggest that your algorithm for checking correct answers is not optimal as you have to input the exact answer to get it right. You may want to check for keywords like so:



            Suppose the answer is photosynthesis produces glucose and oxygen, checking for ‘glucose’ and ‘oxygen’:



            ans = input('what are the products of photosynthesis')
            words = ans.split()
            if all(word in words for word in ('glucose', 'oxygen')):
            print('correct!')
            score += 1
            else:
            print('wrong!')





            share|improve this answer



























              up vote
              2
              down vote













              From what I can see, the variable int_score suggests it holds an integer and in your if statement you write:



              if int_score < '0':
              ...


              In this case, 0 is a string. You need to write it as an int so that it can be compared:



              if int_score < 0:
              ...


              As a side note, might I suggest that your algorithm for checking correct answers is not optimal as you have to input the exact answer to get it right. You may want to check for keywords like so:



              Suppose the answer is photosynthesis produces glucose and oxygen, checking for ‘glucose’ and ‘oxygen’:



              ans = input('what are the products of photosynthesis')
              words = ans.split()
              if all(word in words for word in ('glucose', 'oxygen')):
              print('correct!')
              score += 1
              else:
              print('wrong!')





              share|improve this answer

























                up vote
                2
                down vote










                up vote
                2
                down vote









                From what I can see, the variable int_score suggests it holds an integer and in your if statement you write:



                if int_score < '0':
                ...


                In this case, 0 is a string. You need to write it as an int so that it can be compared:



                if int_score < 0:
                ...


                As a side note, might I suggest that your algorithm for checking correct answers is not optimal as you have to input the exact answer to get it right. You may want to check for keywords like so:



                Suppose the answer is photosynthesis produces glucose and oxygen, checking for ‘glucose’ and ‘oxygen’:



                ans = input('what are the products of photosynthesis')
                words = ans.split()
                if all(word in words for word in ('glucose', 'oxygen')):
                print('correct!')
                score += 1
                else:
                print('wrong!')





                share|improve this answer














                From what I can see, the variable int_score suggests it holds an integer and in your if statement you write:



                if int_score < '0':
                ...


                In this case, 0 is a string. You need to write it as an int so that it can be compared:



                if int_score < 0:
                ...


                As a side note, might I suggest that your algorithm for checking correct answers is not optimal as you have to input the exact answer to get it right. You may want to check for keywords like so:



                Suppose the answer is photosynthesis produces glucose and oxygen, checking for ‘glucose’ and ‘oxygen’:



                ans = input('what are the products of photosynthesis')
                words = ans.split()
                if all(word in words for word in ('glucose', 'oxygen')):
                print('correct!')
                score += 1
                else:
                print('wrong!')






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 11 at 14:13

























                answered Nov 11 at 14:07









                N Chauhan

                1,6841214




                1,6841214






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249507%2fpython-3-typeerror-not-supported-between-instances-of-int-and-str-in-an%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python