Jun-19-2021, 12:16 PM
If you see a pattern like this:
Some style suggestions to write function. Don't use spaces around parentheses on function first line. Do use spaces around operators and after comma. Use four spaces for indentation. For conventions of coding in Python have a look at PEP-8 Style Guide for Python Code. So your function, from pure style perspective, could look like (keep in mind that meaningful names are helpful for users of your code and your future self):
I will not dive into if...elif...else.
a =int(input("Value of a = ")) b =int(input("Value of b = ")) c =int(input("Value of c = "))You should consider refactoring your code. There are lot of repetition and you should avoid it. This principle is called DRY (Don't Repeat Yourself). You can write it like this:
values = [int(input(f'Enter value of {value}: ')) for value in 'abc']This is list comprehension combined with f-strings (formatted string literals). As this is very small list, it would to. If we are talking about huge number of values, then generator expression is preferred. You don't have to have separate names/variables, you can feed unpacked list/generator to your function.
Some style suggestions to write function. Don't use spaces around parentheses on function first line. Do use spaces around operators and after comma. Use four spaces for indentation. For conventions of coding in Python have a look at PEP-8 Style Guide for Python Code. So your function, from pure style perspective, could look like (keep in mind that meaningful names are helpful for users of your code and your future self):
def lineard(x, y, z): return y * y - 4 * x * zYou can feed unpacked argument list to your function like this:
p = lineard(*values)You should be aware that if user enters something which is not convertible to integer the program will blow up and raise error. You could/should write validation function to avoid it.
I will not dive into if...elif...else.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.