×
Namespaces

Variants
Actions

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: lpvalente (05 May 2013)


This example shows how to solve quadratic 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.

This page was last modified on 5 May 2013, at 16:20.
56 page views in the last 30 days.
×