Calculate the discount percentage | Sololearn: Learn to code for FREE!


Calculate the discount percentage

Time to go shopping! Everything in the store has been discounted by 20%. You are given a program that takes the price of an item as input. Complete the program so that it outputs the discounted price to the console.  Sample Input 100  Sample Output 80  Explanation 20 percent of 100 equals to 20 (100 * 20/100), so the discounted price will be 80 (100 - 20).

2/22/2021 5:48:51 AM

Brijesh Nagar

5 Answers

New Answer


If you will show your attempts. It will be more easy to help you for us. Happy coding 👍


Is this one of the Code Coach questions? If yes, try it yourself first! I heard this phrase that says doing it yourself just once is better than hearing 1000 times! (or something along that line since I forgot lol) Hint : if the discount is 20%, how much is the current price? 70? 80%? (This maths is so basic you can definitely do it lol) And then just multiply it with the price input and voila! You just solved the question! Oh, and use parseInt() to change string to number! Happy programming :)


I am very much worried, please give this question to Solve and I am learning JavaScript


// your code goes here var x = (oldPrice * 20/100) var x2 = oldPrice - x Console.log(x2)


//Here's my code a = input() print((lambda x: x-(x*20/100))(a)) but, it's not working. Can anyone tell me what's wrong here, pls...