×
Namespaces

Variants
Actions
Revision as of 09:24, 28 June 2012 by hamishwillee (Talk | contribs)

Archived:How to solve a quadratic equation with PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
CompatibilityArticle
Created: Rafael T. (23 Oct 2008)
Last edited: hamishwillee (28 Jun 2012)

This example shows how to easily resolve second degree equations using PySymbian.

Example Code

#Equations.py
#(c) Rafael Tavares 2008
import appuifw
from math import sqrt
 
op = 1
 
#Calculate
while (op!=2):
 
a = float(appuifw.query(u"A:", "text"))
b = float(appuifw.query(u"B:", "text"))
c = float(appuifw.query(u"C:", "text"))
 
#Delta
 
delta=b*b-4*a*c
 
#The equation answer is not a real number
if (delta<0):
 
appuifw.note(u"Equation answers are not real numbers", "error")
 
#The equation is possible
else:
 
x1=((b*-1)+sqrt(delta))/(2*a)
x2=((b*-1)-sqrt(delta))/(2*a)
 
continueoption=appuifw.popup_menu([u"Delta= "+u"%.0f" % (delta), u"x'= "+u"%.1f" % (x1), u"x''= "+u"%.1f" % (x2), u"Quit"])
 
if (continueoption==3): # Quit selected
 
op = 2


This article was written by Rafael T.

32 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×