+ 4
Trying to solve ice cream for everyone in python core[solved]
Only two test cases seem to come out right money = int(input()) price = int(input()) total = price*10 d = total - money if total<=money: print() if total>=money: print(d) #your code goes here
25 Respostas
+ 5
money = int(input())
price = int(input())
total = price*10
d = total - money
if total<=money:
print(d)
else:
print()
#your code goes here
+ 4
Simba thanks
+ 4
May be first one
+ 3
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.
+ 3
Илья Мирошник it did not work
+ 3
Jayakrishna🇮🇳 only two test case come out right
The other is given negative value instead of positive value
+ 3
Ярослав Вернигора(Yaroslav Vernigora) it did not work
+ 3
#Try this
d = money - total
+ 3
Bob Blunk you solution is not pass all tests:
money = int(input())
price = int(input())
total = price*10
if total >= money:
print (total % money)
+ 3
money = int(input())
price = int(input())
total = price*10
if money >= total:
print (money - total)
How about this one?
+ 2
Pls post description also..
what this code is for?
it output 'd' value if total == money is true. in any other case wont output anything. because 2nd if is inner to 1st if.
+ 2
change <= on <
end second if on elif
or just use only second if because first if useless
+ 2
I think:
if price*10>=money
print(money-total)
Not <=
+ 2
Please, show us your last code again after edits and changes
+ 2
I didn't understand your logic a bit, but some values have a correct but negative value. use the output of the module abs()
+ 2
abs(d)
+ 2
For that sample
if 7*10 <= 80 : print 80 - (7*10) = 10
It should works..
It said do nothing for else part.. but is it expecting something.. ?
edit: Simisola Osinowo
you are doing total-money but it should be money-total
You don't need to put elss part..
remove it and try....
money = int(input())
price = int(input())
total = price*10
d = money - total
if total<=money:
print(d)
+ 2
money = int(input())
price = int(input())
total = price*10
if money >= total:
print (total % money)
Or this one?
+ 2
I think both should work.
+ 2
First yes, second no 😉