Calculate percentage of something in Python?

Greetings, I am currently trying to find a solution to calculate the remainder of a previously calculated number, e.g. 140, from which the percentage number, e.g. 20, entered through an input query

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
4 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
KarlRanseierIII
7 months ago
>>> p=int(input("Prozentsatz eingeben: "))
Prozentsatz eingeben: 20
>>> p/=100
>>> p
0.2
>>> p*140
28.0 # 20 % von 140
>>> 140*(1-p)
112.0 # 80 % von 140

The question is a little blur, because you speak of rest.

ajkcdajefiu
7 months ago
(zahl) * (prozent) = (ergebnis)

if you want to calculate zb 20% of 140, then you enter the numbers in the formula:
140 * 0.2 = 28

your code in Python might look like this:

input_num = 140
percentage = 0.2

result = input_num * percentage
print(result)
cleanercode
7 months ago
letzte_zahl: int = 140

prozentsatz = float(input("Prozentsatz eingeben: "))

ergebnis = (prozentsatz * letzte_zahl) / 100

print(ergebnis)
FrecherKnilch
7 months ago

20/140*100? Sorry, I don’t know about the PythonSyntax, but that’s how I write it in my CNC programs.