Tfw you write something useful that you use frequently

>tfw you write something useful that you use frequently

And you faggots told me learning sneklang would be a waste of time. Jokes on you, I've just shaved MINUTES of work week.

Attached: hepbneut.png (670x1067, 36K)

The hell is this useful for?

Calculating hepatitis b neutralisation values in confirmation tests.

>Jokes on you, I've just shaved MINUTES of work week.
hey man don't be ashamed of starting small. Now shave a few more minutes, and a few more minutes, and before you know it you'll have a noticeably lighter workload due to your programming knowledge.

> 20 lines to calculate a percentage difference
Just use a calculator, bro.

If I'm honest I'm actually kinda proud. Never bothered learning programming before but I'm really enjoying it.

Try to simplify your program, user. You don't need to have the code for reading R1 and R2 in two places.

Take r1 and r2 as command line arguments. Remove the dumb loop, you can type the command again if you want. This program should be 3 lines long.

>entering values on stdin with prompts
Or you could just be a man and enter them on the command-line.
import sys
x, y = int(sys.argv[1]), int(sys.argv[2])
print("%.2f%%" % (100 * (x - y) / x))

I learned python at work and unironically automated so much work I had fuck all to do, but still got paid

Language snobs are the worst kind of programming bugmen

Then it doesn't let me enter the value again, and just repeats the first calculation.

Attached: image001.png (655x1064, 37K)

Put the inputs in the while loop only, not at the start

(12.3 - 52.3) / 12.3 * 100

is -325, and
(5.0 - 9.0) / 5.0 * 100

is -80

How are you getting your results?

Ignore me. You have reversed the inputs, for some reason.

If you're interest in Ruby, this is just:

#!/usr/bin/env ruby
puts "Neutralisation level: #{((ARGV[1].to_f - ARGV[0].to_f) / ARGV[1].to_f * 100).round(2)}%"

in a file, then
$ filename 5 9

produces
44%


There are easier ways to do this: like having these data in a text file and letting Python/Ruby just read from the text file... etc., etc.

Python truly is a dream, set up a shitty GUI program which allows me to download songs from YouTube and put them in a folder which uploads them to Google Play.

It also allows me to tag them so its not tagged autistically, which is a bonus.

>If you're interest in Ruby, this is just
>an unreadable so long it wraps code golf one liner
seems to happen often with rubyposts in this board
I wonder if it's because some of the perltards migrated to ruby

Use argv instead of prompts and make the neutralisation function return a number instead of printing it.

I have never used ruby and I still understand what that code is doing. You don't have to write overly verbose code to calculate a fucking percentage.

>I still understand
everyone with half a brain can understand it, that's not the issue
the issue is writing a 10x harder to read piece of shit instead of splitting it in two lines
there's a reason most style guides have a 80/120 char line limit

x = (ARGV[1].to_f - ARGV[0].to_f) / ARGV[1].to_f * 100
puts "Neutralisation level: #{x.round(2)}%"

still shit
do something like
r1, r2 = argv[0].to_f, argv[1].to_f
puts "whatever: #{(r2-r1)/r2 * 100}"

or even split the r1, r2 assignments on separate lines - improves readability even further