+ 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

2nd Apr 2021, 12:44 PM
Simisola Osinowo
Simisola Osinowo - avatar
25 Answers
+ 5
money = int(input()) price = int(input()) total = price*10 d = total - money if total<=money: print(d) else: print() #your code goes here
2nd Apr 2021, 1:39 PM
Simisola Osinowo
Simisola Osinowo - avatar
+ 4
Simba thanks
2nd Apr 2021, 1:44 PM
Simisola Osinowo
Simisola Osinowo - avatar
+ 4
May be first one
4th Apr 2021, 11:39 AM
Arushi
Arushi - avatar
+ 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.
2nd Apr 2021, 1:20 PM
Simisola Osinowo
Simisola Osinowo - avatar
+ 3
2nd Apr 2021, 1:22 PM
Simisola Osinowo
Simisola Osinowo - avatar
+ 3
Jayakrishna🇮🇳 only two test case come out right The other is given negative value instead of positive value
2nd Apr 2021, 1:34 PM
Simisola Osinowo
Simisola Osinowo - avatar
2nd Apr 2021, 1:35 PM
Simisola Osinowo
Simisola Osinowo - avatar
+ 3
#Try this d = money - total
2nd Apr 2021, 1:40 PM
Simba
Simba - avatar
+ 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)
3rd Apr 2021, 1:20 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
money = int(input()) price = int(input()) total = price*10 if money >= total: print (money - total) How about this one?
3rd Apr 2021, 1:31 PM
JediMastrBob
JediMastrBob - avatar
+ 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.
2nd Apr 2021, 12:52 PM
Jayakrishna 🇮🇳
+ 2
change <= on < end second if on elif or just use only second if because first if useless
2nd Apr 2021, 12:59 PM
Илья Мирошник
Илья Мирошник - avatar
+ 2
I think: if price*10>=money print(money-total) Not <=
2nd Apr 2021, 1:27 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Please, show us your last code again after edits and changes
2nd Apr 2021, 1:37 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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()
2nd Apr 2021, 1:45 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
abs(d)
2nd Apr 2021, 1:47 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 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)
2nd Apr 2021, 2:27 PM
Jayakrishna 🇮🇳
+ 2
money = int(input()) price = int(input()) total = price*10 if money >= total: print (total % money) Or this one?
3rd Apr 2021, 1:32 PM
JediMastrBob
JediMastrBob - avatar
+ 2
I think both should work.
3rd Apr 2021, 1:32 PM
JediMastrBob
JediMastrBob - avatar
+ 2
First yes, second no 😉
3rd Apr 2021, 1:43 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar