• Content Count

  • Joined

  • Last visited

  1. Hello everyone! I am facing some difficulties writing a python program for my school assignment. I am trying to write the taylor series for the arctangent function but i have difficulties getting the differentiation of f(x) done as well as to make the program continue on differentiating as the number of n terms increase. I have attached a photo of the formula and working as well. Any help will be greatly appreciated!
  2. I see, i forget to include the "main()" at the end of the coding. Thank you :)
  3. Hello everyone! I was watching kjdElectronics youtube videos and was looking at his tutorial 7 video. And I was following his coding until this part of the video where he managed to get his calculator program working. But when I try to do it myself, the program did not work as it should. Here are my codings: def add(num1, num2): return num1 + num2 def sub(num1, num2): return num1 - num2 def mul(num1, num2): return num1 * num2 def div(num1, num2): try: return num1 / num2 except ZeroDivisionError: print("Error, you cannot divide by zero") def main(): user_continue = True while user_continue: validInput = False while not validInput: try: myName = input("What is your name?") print("Hello") print(myName) num1 = int(input("Enter num1:")) num2 = int(input("Enter num2:")) operation = input("What do you want to do?(1.addition, 2.subtraction, 3.multiply, 4.division)") validInput = True except: print ("Invalid Command, please try again!") if (operation == '1'): print("answer:") print(add(num1, num2)) elif (operation == '2'): print("answer:") print(sub(num1,num2)) elif (operation == '3'): print("answer:") print(mul(num1, num2)) elif (operation == '4'): print("answer:") print(div(num1, num2)) else: print("Invalid") user_yn = input('Would you like to run another calculation? (Y/N)') if (user_yn != 'Y'): user_continue = False break else: continue And when I run it, I got this: Process finished with exit code 0 Rather than asking me to input my name or num1 and num2. Can anyone help me spot any error in my codings? That will be greatly appreciated! Thanks in advance:)