Adding a % sign at the end of an output number /u/SivadtheDogTrainer Python Education

Hello. I know almost nothing about coding in python (yet). I’m using a script that was made for me by someone some time ago, and I’d like to adjust the way the output looks.

The last few lines of my script are:

# calculate the Z

Z = X/Y + 0.5

print(Z*100)

This script outputs a number, something like 16.25748703875
[* it could be any number, this is just a sample to show the current output format]

I want the script to round the final answer to 2 decimal places, so in this example, to 16.26. I’d also like the script to add a % sign at the end, so it would read: 16.26%
Is there a simple way to do this?
Thank you,
Sivad

submitted by /u/SivadtheDogTrainer
[link] [comments]

​r/learnpython Hello. I know almost nothing about coding in python (yet). I’m using a script that was made for me by someone some time ago, and I’d like to adjust the way the output looks. The last few lines of my script are: # calculate the Z Z = X/Y + 0.5 print(Z*100) This script outputs a number, something like 16.25748703875 [* it could be any number, this is just a sample to show the current output format] I want the script to round the final answer to 2 decimal places, so in this example, to 16.26. I’d also like the script to add a % sign at the end, so it would read: 16.26% Is there a simple way to do this? Thank you, Sivad submitted by /u/SivadtheDogTrainer [link] [comments] 

Hello. I know almost nothing about coding in python (yet). I’m using a script that was made for me by someone some time ago, and I’d like to adjust the way the output looks.

The last few lines of my script are:

# calculate the Z

Z = X/Y + 0.5

print(Z*100)

This script outputs a number, something like 16.25748703875
[* it could be any number, this is just a sample to show the current output format]

I want the script to round the final answer to 2 decimal places, so in this example, to 16.26. I’d also like the script to add a % sign at the end, so it would read: 16.26%
Is there a simple way to do this?
Thank you,
Sivad

submitted by /u/SivadtheDogTrainer
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *