Question

for this code fix the smtax error this is a python code for some reason my...

for this code fix the smtax error this is a python code for some reason my code isnt liking my returns and it bring up other symtax error so fix the following code

answer should pop out

the following when runned

1/ 2  + 1/ 3  + 1/ 12   =  11/12

z=' '
def math(x,y):
    global z
    if y==0 or x==0:
        return
    if y%x ==0:
        z=("1/"+str(int(y/x))
        return
     if x%y ==0
        z+=(int(x/y))
    #return
    if x>y:
        z+=(int(x/y)," + ")
        math(x%y,y)
    #return
    a=int(y/x)+1
    z+=("1/"+str(a)+" + ")
    math(int(x*a-y),int(y*a))
x=11
y=12
math(x,y)
print(z,"=",str(x)+"/"+str(y))

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def math(x,y):
    global z
    if y==0 or x==0:
        return
    if y%x ==0:
        z=("1/"+str(int(y/x))
        return
     if x%y ==0
        z+=(int(x/y))
    return z
    if x>y:
        z+=(int(x/y)," + ")
        math(x%y,y)
return z+
    a=int(y/x)+1
    z+=("1/"+str(a)+" + ")
    math(int(x*a-y),int(y*a))
x=11
y=12
math(x,y)
print(z,"=",str(x)+"/"+str(y))

Add a comment
Know the answer?
Add Answer to:
for this code fix the smtax error this is a python code for some reason my...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • AND logic gate simulation in Python: Please fix the code below so that it efficiently performs...

    AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y):     if x == True and y == True:         return True        else:         return False    def main():     x = bool(input("Please...

  • Python 3 Can anyone make my Python code more readable, by breaking up the code into...

    Python 3 Can anyone make my Python code more readable, by breaking up the code into smaller chunks using functions. If a piece of code tries to do several things, it should be broken up into several different functions. print("chatbot: Hello, I am chatbot. What is your name?") name = input("") print("chatbot: Nice to meet you "+name+". Tell me now, what is your age?") age = int(input("")) if age >= 16 and age <= 25: print("We are the same age!...

  • My code in python is wrong with this error: "Your result seems to be incorrect. I...

    My code in python is wrong with this error: "Your result seems to be incorrect. I expect a polynomial expression." How do I fix this?? Indefinite Integration Consider the following integral: at dxx log x Solve this integral symbolically. Store your result in a variable result, which should be a sympy expression Starter code (click to view) 1 import sympy 2 from sympy import log Answer* 4 def result(m): 5 m-x**n sympy.log(x) result-sympy.integrate( m, x) 7 print (result)

  • i have my code all the way complete except one syntax error code( import math f=open("101primes.txt")...

    i have my code all the way complete except one syntax error code( import math f=open("101primes.txt") primes=[] for line in f: primes.append(int(line)) thelist=[2692493, 2692503, 4632703, 8767843, 7982119, 7983121, 13065521 , 11505341 ,11505343 ,14123649 ,14123651] for i in thelist: oof=1 TV=int(math.sqrt(i)) for x in primes: if(x>TV): break elif(i%x == 0): oof=0 break if(oof): print str(i)+ "is a prime number" else: print str(i)+ "is not a prime number" )

  • Page 3 of 7 (Python) For each substring in the input string t that matches the...

    Page 3 of 7 (Python) For each substring in the input string t that matches the regular expression r, the method call re. aub (r, o, t) substitutes the matching substring with the string a. Wwhat is the output? import re print (re.aub (r"l+\d+ " , "$, "be+345jk3726-45+9xyz")) a. "be$jk3726-455xyz" c. "bejkxyz" 9. b. "be$jks-$$xyz" d. $$$" A object a- A (2) 10. (Python) What is the output? # Source code file: A.py class A init (self, the x): self.x-...

  • I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import...

    I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2):     product = num1 * num2     result = a.add(product, product)     return result     def main():     num1 = 4     num2 = 3     answer = multiply(num1, num2)     print("The answer is", answer) if __name__ == "__main__":     main() arithmetic module: def add(x, y):     z = x + y     return z Refer to Code...

  • What is wrong with my python code. I am receiving this error: Traceback (most recent call...

    What is wrong with my python code. I am receiving this error: Traceback (most recent call last): File "C:/Users/owner/Documents/numberfive.py", line 7, in if age > 18: TypeError: unorderable types: str() > int() My code is age= input("Enter your age:") if age > 18: print("You can vote.") else: print("You can't vote.") if age > 64: print ("You're a Senior Citizen...you deserve two votes") endofprogram = input("Please hit enter to exit from this program:")

  • Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that...

    Hello, In Python Enhance the prior assignment by doing the following 1) Create a class that contain all prior functions MyLib # This function adds two numbers def addition(a, b): return a + b # This function subtracts two numbers def subtraction(a, b): return a - b # This function multiplies two numbers def multiplication(a, b): return a * b # This function divides two numbers # The ZeroDivisionError exception is raised when division or modulo by zero takes place...

  • Write a python program write a function numDigits(num) which counts the digits in int num. Answer...

    Write a python program write a function numDigits(num) which counts the digits in int num. Answer code is given in the Answer tab (and starting code), which converts num to a str, then uses the len() function to count and return the number of digits. Note that this does NOT work correctly for num < 0. (Try it and see.) Fix this in two different ways, by creating new functions numDigits2(num) and numDigits3(num) that each return the correct number of...

  • 1. Questions Python Code: For each line of code, write the type of error (syntax, semantics,...

    1. Questions Python Code: For each line of code, write the type of error (syntax, semantics, runt-time), cause of the error, and your fix. (1) def fun(num letter) (2) num == 7 + num (3) return 'num' - letter (4) result = fun(5, x) 2. Question Python Code: Run the code below to check the outputs of the print() call on lines 12. And : A) Analyze the application of the accumulation pattern and answer the following questions: #1. a....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT