+ 2
What I did wrong in this?? Help me friends.
n = int(input) If n%2!=0: print ("Weird") elif n%2==0 or n%2!=0 in range (2,5): print ("Not Weird") elif n%2==0 in range(6,20): print("Weird") elif n%2==0 and n>20: print ("Not Weird") """ The problem is when i give input 16 it shows ("Not Weird") , But it should print ("Weird") """
11 ответов
+ 2
https://code.sololearn.com/cmRdqP9Owjsr/?ref=app
Some probs you had
+ 1
try this
n = int(input())
if n%2!=0:
print ("Weird")
elif n%2==0 and n in range (2,6):
print ("Not Weird")
elif n%2==0 and n in range(6,21):
print("Weird")
elif n%2==0 and n>20:
print ("Not Weird")
+ 1
This codes is well ordered.
For me i think that for those conditional statememts they should be imposed on n not on n%2
HOPE THIS HELPS
https://code.sololearn.com/c8VOf5fIpbQO/?ref=app
+ 1
Here 16 is not a weird number,and the smallest weird number is 70
A number is said to be weird if the sum of proper divisors of that number(except itself) are greater than the given number.
Example:the number 70
The divisors of 70 are 1,2,5,7,10,14 and 35.whose sum is 74.
Here 74 is greater than 70
0
what do you mean by:
n%2!=0 in range(2,5)
or
n%2==0 in range(6,20)
0
If the number is not even in range means print...
0
to do so,
if n%2 != 0 and n in range(2,5)
and the second case
if n%2 == 0 and n in range(6,20)
0
but I think that your first elif condition should be
elif n%2==0 and n in range(2,5)
as the case n odd is already handled in the if statement.
0
n = int(input())
if n%2!=0:
print ("Weird")
elif n%2==0 or n%2!=0 in range (2,5):
print ("Not Weird")
elif n%2==0 in range(6,20):
print("Weird")
elif n%2==0 and n>20:
print ("Not Weird")
""When i give input 6 it shows Not Weird.. But it should print Weird... Still i don't get this 😣
0
Last two statement is wrong i think so.. First statement is passed.. Other statements failed
0
Thanks bro.. You saved me... It work's.....