import math import os def main(): nonUnitX = input("ENTER THE X-COORDINATE:") nonUnitY = input("\nENTER THE Y-COORDINATE:") unitX, unitY = UnitizeVector(nonUnitX, nonUnitY) print("\nTHE UNITZIED VERSION OF <%.2f, %.2f> IS <%.2f, %.2f>") % (nonUnitX, nonUnitY, unitX, unitY) def UnitizeVector(nonUnitX, nonUnitY): divisonRatio = math.sqrt(nonUnitX ** 2 + nonUnitY ** 2) unitX = nonUnitX unitY = nonUnitY unitX /= divisonRatio unitY /= divisonRatio return(unitX, unitY) main() def main(): s_1 = raw_input("ENTER THE FIRST STRING:") s_2 = raw_input("\nENTER THE SECOND STRING:") s_3 = raw_input("\nENTER THE THIRD STRING:") s_1,s_2,s_3 = Alphabetize(alphaMe1 = s_1, alphaMe2 = s_2, alphaMe3 = s_3) print("THE STRINGS IN ALPHABETICAL ORDER:\n%s\n%s\n%s") % (s_1,s_2,s_3) def Alphabetize(alphaMe1,alphaMe2,alphaMe3): alphaMe1 = alphaMe1.upper() alphaMe2 = alphaMe2.upper() alphaMe3 = alphaMe3.upper() string1 = sorted(alphaMe1) string2 = sorted(alphaMe2) string3 = sorted(alphaMe3) s_1 = "".join(string1) s_2 = "".join(string2) s_3 = "".join(string3) return(s_1,s_2,s_3) main() def main(): lower = input("ENTER THE LOWER RANGE: ") upper = input("ENTER THE UPPER RANGE: ") while (lower < 1 or lower > 30) or (upper > 30 or upper < 1): print"INVALID RANGE\n" lower = input("ENTER THE LOWER RANGE: ") upper = input("ENTER THE UPPER RANGE: ") DisplaySquaresCubes(lower, upper) def DisplaySquaresCubes(lower, upper): for i in range(lower, upper + 1): square = i ** 2 cube = i ** 3 print("%d\t%d\t%d") % (i, square, cube) return main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question