Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 479 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slope Calculator

#1
Formula for slope:
y2 - y1
______

x2 - x1

I made a simple calculator, but it took me so long because I missed a ")".

I know it's simple, but yeah :smile:

I will be making more stuff, I might send this to my math teacher for the lulz (we learned slope like a long time ago but yeah, we are doing something now that INVOLVES slope).

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

Reply

#2
dafuq is a validity check
Reply

#3
Gah, do validity checks, at the very least. D:
Reply

#4
Just makes sure that the entered value is an integer.
You directly converted the input to an integer, so any invalid values will result in an error.

I mean, yeah, this is simple as fuck, but sometimes that little extra step is all it needs to be a decent bit of code.
Reply

#5
How would I do that?
Sorry, I am new to Python :l
Reply

#6
There are a few ways, but one of the easiest is try-except.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

and so on.

Mind you I said this was one of the easiest, not one of the best. There are other, more suitable ways of doing it.
Reply

#7
What does try do, and what does except do?
Reply

#8
Quote:(11-09-2013, 04:54 AM)Kirika Yūmura Wrote:

[To see links please register here]

People like you are why I'm depressed.

[To see links please register here]


Please kill yourself, I recommend a drug overdose.

I use python 3.3
Reply

#9
Quote:(11-09-2013, 04:49 AM)Tear Wrote:

[To see links please register here]

What does try do, and what does except do?

People like you are why I'm depressed.

[To see links please register here]

Reply

#10
It's kinda like if-else, but for errors:

Try is exactly what is sounds like, it tries to perform a bit of code.
Normally, when something causes an error, like trying to convert a string with letters to an integer, the script will cease to work and spit out an error.

If you use try-except, Except will catch that error. Usually that's used to display a more helpful error message, but it can also be used to very easily check if something is a valid instance.





Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The above code produces a TypeError, since "Hello!" is not a valid integer, and the script will never reach the second print. So to fix that, you would use try-except.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The code will still print out the error, but now it continues on to the final print. You can also make it silent by changing print(e) to pass.

And just so you know, any try MUST have a matching except, even if you're not going to use it. An unused except must, at the very least, contain a pass statement.



@Kirika; Sometimes docs are a little hard to understand for the uninitiated, get the sand out of your vagina.

@Tear(previous post); The 2.x docs are largely the same as the 3.x docs, and even when they aren't, will usually link to the recommended version at the top. Also, there's a drop-down at the top of all doc pages that will move you to the valid page for your selected version.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through