+ 1
[Solved] Learning Python IF statement V training problem
I've written the code, but it doesn't pass the 4th secret test, I don't understand, what's the problem. Code: money = int(input()) price = int(input()) costs = price * 10 if ( (costs <= 100) and ( costs <= money) and (money > 0) and (price > 0) ): print (money - costs) I saw that 4 test checks the output in case of negative result, but I have a condition (costs <= money). Any idea, what's wrong? ------ UPD. Solution: money = int(input()) price = int(input()) total = price * 10 if money >= 0 and price >=0: remaind = money - total if remaind <= 100 and remaind >= 0: print (remaind)
22 Respostas
+ 16
Their might be some bugs in the written statement which is causing error. Take an look here
The line “Don’t print anything if money > 100” should be like “Don’t print anything if the remainder is > 100”. As at current statement the 4th test case is failing continuously do either the test case contain bug or the statement so for now this assumption is much more validate.
money = int(input())
price = int(input())
total = price*10
#your code goes here
if money >=0 and price>=0:
remaind = money - total
if remaind<=100 and remaind>=0:
print (remaind)
Than the problem should be fixed.
https://www.sololearn.com/discuss/2575215/?ref=app
+ 3
It‘s not a bug. Try this...
money = int(input())
price = int(input())
total = price*10
You want to output the remaining money IF:
1. total is NOT bigger than money
OR
2. total is NOT bigger than 100
Write this out as one if statement and you‘re good to go.
+ 3
Георгий Ерёмин In your very first variant: Delete all the parentheses in the if statement, change and to or and delete the second equal sign.
+ 2
Would have been great if you had posted the code coach
+ 1
GAWEN STEASY, you were right, there might be "Don't print anything if remainder > 100"
Thanks a lot!
The working code is:
money = int(input())
price = int(input())
total = price * 10
if money >= 0 and price >=0:
remaind = money - total
if remaind <= 100 and remaind >= 0:
print (remaind)
0
The task:
Let's imagine you want to buy an ice-cream for 10 of your friends.
Write a program that will take the money you have and the price of one ice-cream, and will output the remaining money only if you can buy that ice-cream for your all 10 friends.
Sample Input
80
7
Sample Output
10
Explanation
To buy 10 ice-creams you need 7*10 = 70.
The remaining money is 80-70 = 10.
Do not output anything if the total price is above 100.
0
>Try this
https://code.sololearn.com/cbNWT7Q0wD1R/?ref=app
The same result, secret test #4 is failed
0
If money < cost then I think it fails. Need no output..
Edit :
For your original code, try including conditions for money=0,price=0.
Further error means I guess a bug. Others facing same.
0
>If money < cost then I think it fails. Need no output..
Yes, that's why i check this condition ( costs <= money) in my start version.
0
>Check it again
Simba, the 4th test is failed again
0
>For your original code, try including conditions for money=0,price=0.
Jayakrishna🇮🇳, I tried conditions money and price >= 0 .
Ok, I'll consider this as a bug.
Thanks!
0
Георгий Ерёмин am not sure about that. But on reading it again that I guessing if price is over than money then you cant buy any. But in this case it's not said not to print any so remaining is same money may needed to print. A wild guess upon checking all condition.
0
Jayakrishna🇮🇳, I understand the phrase in task
"... will output the remaining money only if you can buy that..."
so that I shouldn't print the remaining money if (costs > meney)
0
Oh. I miss read it. Not seen 'only if'.. Ok then may be bug..
0
_cm_, that was my very first variant, it doesn't work because of test #4
money = int(input())
price = int(input())
total = price * 10
if ( (total <= 100) and (total <= money) ):
print (money - total)
0
This works. The last one.
0
Thanks... this worked and i finally get why!
money = int(input())
price = int(input())
total = price * 10
if money >= 0 and price >=0:
remaind = money - total
if remaind <= 100 and remaind >= 0:
print (remaind)
0
guys no im on a different question for quiz 4 its about:Fill in the blanks to take a number from input and output "Pass", if it s greater than 70.
grade =
(input()) grade > :("Pass")/ and its broken for me🤣🤣🤣 silly website😭🤭🤗😉🥳🤩😌😏😍🥰😊☺️😘😚🥲🙂😙😗🙃😀😃😄😁
0
hahahahahahahahahha
0
grade = int(input())
if grade > 70:
print("Pass")