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.
python python-3.x syntax-error
add a comment |
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.
python python-3.x syntax-error
add a comment |
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.
python python-3.x syntax-error
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
python python-3.x syntax-error
edited Nov 11 at 14:09
molbdnilo
39.9k32152
39.9k32152
asked Nov 11 at 14:02
Zakariya Islam
14
14
add a comment |
add a comment |
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!')
add a comment |
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!')
add a comment |
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!')
add a comment |
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!')
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!')
edited Nov 11 at 14:13
answered Nov 11 at 14:07
N Chauhan
1,6841214
1,6841214
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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