0
This Python challenge is killing me! (Ice Cream for Everyone python if statements challenge)
https://www.sololearn.com/coach/127?ref=app 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 7*10 = 70. 10 is remaining money (80-70). Do not output anything if the total price is above 100. ________ money = int(input()) price = int(input()) #your code goes here _______ I've tried everything 😫
6 Respostas
+ 3
I am not pro .So thanks for sharing the explanation .
Can you please show your code it would be much better to understand what your mistake was.
+ 1
I found the answer like this.
money = int(input())
price = int(input())
total = price*10
#your code goes here
remaing = money - total
if money >= total:
print(remaing)
0
I found the answer courtesy of @Steven M
money = int(input())
price = int(input())
#your code goes here
price*=10
if (money-price)<0:
print()
else:
print(money-price)
I was definitely overthinking this 😅
0
print('Money you have: ',money_you_have:=int(input()))
print('Price of one ice cream: ',price_of_one_icecream:=int(input()))
n=price_of_one_icecream*10
if(money_you_have>=n):
remaining_money=money_you_have-n
print('Money remaining after spending: ',remaining_money)
else:
print('You dont have enough money')
0
Mine was slightly different:
money = int(input())
price = int(input())
total = price*10
if(total <= money):
print(money%total)
0
money = int(input("Total money : "))
price = int(input("Prive for one ice cream : "))
if (h :=price*10) < money:
if h <= 100:
money -= h
print(money)