Pls I need help with this question n I want to understand the solution to the question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls I need help with this question n I want to understand the solution to the question

You are making a game! The player tries to shoot an object and can either hit or miss it. The player starts with 100 points, with a hit adding 10 points to the player’s score, and a miss deducting 20 points. Your program needs to take 4 action results as input ("hit" or "miss"), calculate and output the player’s remaining points. Sample Input hit hit miss hit Sample Output 110 Explanation: 3 hits add 30 points, one miss deducts 20, making the total points equal to 110.

22nd Sep 2021, 5:20 PM
Hubert Kingsley Ocran
Hubert Kingsley Ocran - avatar
4 Answers
+ 3
There's a saying that"if you want something to be done well, u would have to do it urself" I have found the solution to my own problem total=100 i=1 while i<=4: x=input() i+=1 if x=="hit": total +=10 else : total -=20 print (total ) the while loop i<=4 allows the code to take only 4 inputs. so for every input , if x equals hit , 10 is added to" total ". if x equals miss for every input ,20 is deducted from "total ".
25th Sep 2021, 2:43 PM
Hubert Kingsley Ocran
Hubert Kingsley Ocran - avatar
+ 2
Kingsley Ocran You have to take 4 input, hit or miss. Initially given point is 100. Every hit will give you 10 point and every miss will deduct 20 point. https://code.sololearn.com/cWri9DmD1BTN/?ref=app
22nd Sep 2021, 6:03 PM
I Am a Baked Potato
I Am a Baked Potato - avatar
+ 1
Please, show your attempt/code and explain your problem is clearly. So, we can help. Thanks for understanding. Happy coding!
22nd Sep 2021, 6:01 PM
mesarthim
mesarthim - avatar
+ 1
Kingsley Ocran Good job!
25th Sep 2021, 2:52 PM
I Am a Baked Potato
I Am a Baked Potato - avatar