Retired Staff
Join Date: May 2010
Location: Portland, OR
Posts: 2,039
Rep: 69
(Unique: 58)


Thread Tools 
Sponsored Links  
Advertisement 

Sponsored Links  
Advertisement 

>>> x = 123456789.123456789 >>> print '%20.5f' % x 123456789.12346 >>> print '%020.5f' % x 00000123456789.12346 >>> print '%020.2f' % x 00000000123456789.12 >>> y = 15 >>> print '%7d' % y 15 >>> print '%07d' % y 0000015 >>> z = "abcdefghijklmnopqrstuvwxyz" >>> print '%35s' % z abcdefghijklmnopqrstuvwxyz >>> print '%035s' % z abcdefghijklmnopqrstuvwxyz
print 'Welcome to the Pig Latin Translator!' original = raw_input("Enter a word: ") if len(original) > 0 and original.isalpha(): print original else: print "You must enter a word to proceed."
def cube(number): return number ** 3 def by_three(number): if number / 3 >= 0 by_three: return cube(number) else: by_three return False
def cube(number): return number ** 3 def by_three(number): if number / 3 >= 0 by_three: return cube(number) else: by_three return False
def cube(number): return number ** 3 def by_three(number): if number / 3 >= 0 by_three: return cube(number) else: by_three return False
def by_three(number): # This line is ok if number / 3 >= 0 by_three: # Remove by_three from this line. Also, you should # compare the modulus of variable number and 3 to 0, not divide by # 3 and compare to 0 because, unless the number is negative, # all numbers are divisible by 3 and will return a float larger than 0. return cube(number) # Not indented properly else: by_three return False # Once again, remove by_three as it's a syntax error
def cube(number): return number ** 3 def by_three(number): if number % 3 == 0: # number % 3 will return 0 (which will make the expression true) only if there is no remainder after dividing a number by 3 return cube(number) # Properly indented else: return False # removed by_three

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Show Printable Version Show Printable Version
Email this Page Email this Page


Posting Rules  