+ 2

i have to solve it

SAY IT SOLVED You are playing a game at your local arcade, and you receive 1 ticket from the machine for every 12 points that you score. You want to purchase a squirt gun with your tickets. Given your score, and the price of the squirt gun (in tickets) are you able to buy it? Task Evaluate whether or not you have scored high enough to earn enough tickets to purchase the squirt gun at the arcade. Input Format The first input is an integer value that represents the points that you scored playing, and the second input is an integer value that represents the cost of the squirt gun (in tickets). Output Format A string that say 'Buy it!' if you will have enough tickets, or a string that says 'Try again' if you will not. Sample Input 500 40 Sample Output Buy it! code : points = int(input()) cost = int(input()) if ((points/(12*cost))>=1): print("Buy it!") else : print("Try again")

15th May 2020, 11:16 AM
Akshat Jain
16 odpowiedzi
+ 2
What have you tried so far? Would you share, so that we can find issues in your code, please?
15th May 2020, 11:19 AM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 2
Okay, Lets look at the whole problem. Lets say i have 200 points and the prize i want is 10 tickets. (The input would be 200, then 10) I can exchange POINTS for tickets at a rate of 12 points/per ticket To know how many tickets i can get from my points i need to divide my TICKETS by 12, right? What about the extra points? They dont matter because they arent enough for another ticket so... 200 // 12 = 16 (16 is the amount of tickets i could get) Remember, the prize was 10 tickets, so if my tickets(16) minus the price(10) is over 0, then i can buy the prize!
15th May 2020, 11:42 AM
Slick
Slick - avatar
+ 2
Your variables are good. your if statement should be: if (points//12) - cost >= 0: I want you to know WHY though
15th May 2020, 4:26 PM
Slick
Slick - avatar
+ 2
points=int(input()) cost=int(input()) #Use this condition to solve it. if (points//12)>=cost: print("Buy it!") else: print("Try again") #Try to find how it works.
17th May 2020, 4:58 AM
Jenson Y
+ 1
Alright cool, can you post your attempt please? It'll be much easier to help
15th May 2020, 11:19 AM
Slick
Slick - avatar
+ 1
Also you may want to take off all the redundant parenthesis. Especially the one after ">=1"
15th May 2020, 11:28 AM
Slick
Slick - avatar
0
points = int(input()) cost = int(input()) if ((points/(12*cost))>=1): print("Buy it!") else : print("Try again") #what is the mistake here
15th May 2020, 11:20 AM
Akshat Jain
0
Its the setup in your equation. Take the equation out of the code. This is yours: points / (12 * cost) The problem says for every 12 points you get 1 ticket. So that would mean: points // 12 = ticket. ( "//" is not a typo) I think you got it from here
15th May 2020, 11:24 AM
Slick
Slick - avatar
0
Slick yes i have also tried it... but its not working!!
15th May 2020, 11:26 AM
Akshat Jain
0
Slick no change after removing parentheses
15th May 2020, 11:31 AM
Akshat Jain
0
Post your updated code, lets see what you have now.
15th May 2020, 11:32 AM
Slick
Slick - avatar
0
points = int(input()) cost = int(input()) if (points//(12*cost))>=1: print("Buy it!") else : print("Try again") updated
15th May 2020, 11:33 AM
Akshat Jain
0
Slick didnt get u.... please tell me whats the mistake in my code
15th May 2020, 4:23 PM
Akshat Jain
0
points = int(input()) tickets = int(input()) if int(points / 12) >= tickets: print("Buy it!") else: print("Try again")
16th May 2020, 12:11 AM
Jonathan Alvarado
Jonathan Alvarado - avatar
0
c=int(input()) d=int(input()) e=d*12 if c>=e: print("Buy it!") else: print("Try again") try this it will execute!
16th May 2020, 9:18 AM
CharanTej Chetty
CharanTej Chetty - avatar
0
#include <stdio.h> int main() { int points,rate; scanf("%d %d",&points,&rate); if(points/12<rate){ printf("Try again"); }else if(points/12>=rate){ printf("Buy it!"); } return 0; }
15th Jan 2021, 5:13 PM
SRI SIVA LAKSHMANA REDDY DWARAMPUDI
SRI SIVA LAKSHMANA REDDY DWARAMPUDI - avatar