How can you write % in python, just like 10% or 15% then use the value to calculate? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can you write % in python, just like 10% or 15% then use the value to calculate?

e. g 1.5% of 3, how can that be translated to python language

15th Jan 2023, 3:05 PM
Wiseman Umanah
Wiseman Umanah - avatar
3 Answers
+ 5
Wiseman Umanah , the percentage character *%* has different meanings in python: > it is used as operator for modulo calculations > it is also used as a kind of place holder when formating date / time expressions for input / output. > but what you can do is writing a function or a class that can parse an input string like *1.5% of 3* and calculate the result.
15th Jan 2023, 4:41 PM
Lothar
Lothar - avatar
+ 2
Wiseman Umanah 1.5/100*3
15th Jan 2023, 3:18 PM
BORN-LOSER
BORN-LOSER - avatar
0
Rajat C Thanks bro I know about that formula i was thinking maybe there's a special operator or method for percentage
15th Jan 2023, 3:33 PM
Wiseman Umanah
Wiseman Umanah - avatar