Showing posts with label simple calculator. Show all posts
Showing posts with label simple calculator. Show all posts

Monday, 11 May 2015

Cross-multiplication Calculator (The Rule Of Three)

In this post I will put a code tha makes a 'calculator' that uses cross-multiplication (or like the title says, The Rule Of Three).

Well, (Wikipedia link-here) one can cross-multiply to determine the value of a variable.

In this case it's like:

a * x = b * c
Which ends up (for the 'x' variable) in:

 x = c * b / a

Thursday, 7 May 2015

Using tkMessageBox

Now I'm going to use the module "tkMessageBox", which is used to display message boxes, first in a simple code in order to show how it goes, then using it with a previous posted example :P.

The simple code has been a used with one of the functions that "tkMessageBox" provides (for a little bit more of information you can go to the next link : Python Tkinter tkMessageBox;  or this other one for the code of the message box of the first image in this post)

Anyway, this is the simple code (a warning will be shown when the user clicks the button that says "Warning"):

import Tkinter as tk
import tkMessageBox

root = tk.Tk()

def info():
   tkMessageBox.showwarning("Warning", "Resources changed")

tk.Button(root, text = "Pop up", command = info).pack()

root.mainloop()

Saturday, 25 April 2015

Creating a simple Reynolds number calculator

This time I'm posting a simple Reynolds number calculator, it has been done without using the class mechanism because I was getting some wierd results.

The image that is going to be used is the next one:

The code is the next one:

from Tkinter import *

def calc_Re():
    """
    Re : Reynolds Number
         (Adimensional number used to determine
          if a fluid flow is laminar or turbulent type)
    Re = velocity * diameter / kinematic_viscosity
    Re =  v__val  *  d__val  /      nu_val
    (row = 3, column = 1)
    """
    if nu_val.get() == 0:
        print "Kinematic viscosity must be greater than zero"
        lab4.config(text="Nu = 0")