0 votes
2 views
in Python
closed

How would I decide if a given integer is between two different numbers (for example more prominent than/equivalent to 10000 and not exactly/equivalent to 30000)?

I'm utilizing 2.3 IDLE and what I've endeavored so far isn't working:

if number >= 10000 and number >= 30000:

print ("you have to pay 5% taxes")

closed

## 4 Answers

0 votes
by (25.7k points)
selected

Best answer
To determine if a given integer is between two different numbers (e.g., greater than or equal to 10000 and less than 30000), you need to adjust your conditional statement. Currently, you are using number >= 30000, which would include numbers greater than or equal to 30000. Instead, you should use number < 30000 to exclude 30000. Here's the corrected code:

if 10000 <= number < 30000:

print("You have to pay 5% taxes")

In the updated code, the and operator is used to check two conditions: number >= 10000 ensures that the number is greater than or equal to 10000, and number < 30000 ensures that the number is less than 30000. If both conditions are satisfied, the message "You have to pay 5% taxes" will be printed.
0 votes
by (26.4k points)

Try the below code:

if 10000 <= number <= 30000:

pass

Check this docs for more details

Are you interested to learn the concepts of Python? Join the python training course fast!

0 votes
by (15.4k points)
if 10000 <= number < 30000:

print("A 5% tax is applicable.")

In this code, the conditional statement checks if the number is greater than or equal to 10000 and less than 30000. If this condition is met, the program will print the message "A 5% tax is applicable."
0 votes
by (19k points)
if 10000 <= number < 30000:

print("5% tax applies.")

In this code, the conditional statement checks if the number falls between 10000 (inclusive) and 30000 (exclusive). If the condition is true, it will print the message "5% tax applies."

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+5 votes
1 answer
0 votes
1 answer