All Activity

This stream auto-updates     

  1. Yesterday
  2. Last week
  3. Earlier
  4. Matthew

    My Code Is Not Working

    Oh my goodness, thanks so much for helping me with all of this - i feel super embarrassed that I didn't see this myself haha but thanks so much!
  5. BigNibba

    My Code Is Not Working

    The variable var1 is missing an extra bracket '(' . int(input("Enter num1: ") **)** (ignore ** there to show what u need to add). And do the same for 'var2'
  6. Matthew

    My Code Is Not Working

    Hey guys, I have been watching kjdelectronics on his python tutorial videos and have recently gotten to the part where you build a calculator, but I'm having trouble in the finalization process of it all. My code seems to be flawed - I keep getting a syntax error and have no idea why because I have copied the code exactly as he presents it in the video. I was wondering if anyone could look at it and tell me where my issue (bug) is located. Here is my code and a screenshot of the syntax error. #Returns the sum of num1 and num2 def add(num1, num2): return num1 + num2 #Returs the result of subtracting num1 - num2 def sub(num1, num2): return num1 - num2 #Returns the result of multiplying num1 * num2 def mul(num1, num2): return num1 * num2 #Returns the result of dividing num1 / num2 def div(num, num2): return num1 / num2 def main(): operation = input("What do you want to do? (+, -, *, /): ") if(operation != '+' and operation != '-' and operation != '*' and operation != '/'): #invalid operation print("You must enter a valid operation") else: var1 = int(input("Enter num1: ") var2 = int(input("Enter num2: ") if(operation == '+'): print(add(var1, var2)) elif(operation == '/'): print(div(var1, var2)) elif(operation == '-'): print(sub(var1, var2)) else: print(mul(var1, var2)) main()
  7. Hello, thank you for your effort in this tutorial and i know it is pretty old and you won't propably answert but maybe someone know what to do. I wrote my code but i have little problem i guess its beacuse of the fact that i created 2 functions - shape and shape_random instead of dealing with it in one function. But i want to know why does error occur, what's the reason. So everything works if we choose 1, 2 or 3 but then when loop comes to begining and starts over i get error after choosing 1 or 2 (does't matter if previous choice was 1 or 2) . Sorry if my English hurt your eyes. Here is code: import random import turtle def random_color(): num=random.randint(0,5) if(num == 0): return 'yellow' elif(num==1): return 'red' elif(num==2): return 'blue' elif(num==3): return 'green' elif(num==4): return 'brown' elif(num==5): return 'purple' def shape(shape, coord1, coord2): if(shape==0): #Square turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20, steps=4) elif(shape==1): #Triangle turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20, steps=3) elif(shape==2): #Circle turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20) else: print("Wrong number.") def random_shape(coord1, coord2): random_shape = random.randint(0,2) if (random_shape == 0): # Square turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20, steps=4) turtle.penup() turtle.forward(100) elif (random_shape == 1): # Triangle turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20, steps=3) turtle.penup() turtle.forward(100) elif (random_shape == 2): # Circle turtle.penup() turtle.goto(coord1, coord2) turtle.color(random_color()) turtle.pendown() turtle.circle(20) turtle.penup() turtle.forward(100) def main(): while True: x = - 300 y = 100 print("Welcome.") print("-=-=-=-=-=-=-=-=-=-=-=-=-=-") print("\nMain Menu:") print("\n1.Draw a specific figure") print("\n2.Draw random figure") print("\n3.Exit") print("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-") choice=int(input("What's your decision?")) if(choice==1): print("Figures Menu:") print("0.Square") print("1.Triangle") print("2.Circle") specific=int(input("What's your decision?")) number=int(input("How many times do u want to draw that figure? 1-10")) if number <0 or number >11: print("U aren't allowed to print this amount of figures.") continue for i in range(0,number): if (i==3 or i==6 or i==9): x = -300 y -= 50 shape(specific, x, y) x += 100 turtle.done() elif(choice == 2): number = int(input("How many times do u want to draw? 1-10")) if number<0 or number>11: print("U aren't allowed to print this amount of figures.") continue for i in range(0,number): if (i==3 or i==6 or i==9): x = -300 y -= 50 random_shape(x, y) x+=100 turtle.done() elif(choice ==3): print("The program will close.") break main() Traceback (most recent call last): File "C:/Users/USERNAME/PycharmProjects/Project1/Test2.py", line 122, in <module> main() File "C:/Users/USERNAME/PycharmProjects/Project1/Test2.py", line 101, in main shape(specific, x, y) File "C:/Users/USERNAME/PycharmProjects/Project1/Test2.py", line 34, in shape turtle.penup() File "<string>", line 5, in penup turtle.Terminator Process finished with exit code 1
  8. Kevin

    Introducing Arduino

    I recommend starting with blink. Play with that and get the LED on the board to blink at different rates. Then move the LED onto a bread board with a resistor. Once you do that you should have your feet wet.
  9. Light

    School Project using C++

    i just want to ask what school project is good for c++ program?
  10. Ronj1952

    Not compiled code doesn't run

    I found your problem you use the symbols < > what you should be using is ( ) I realize that you probably already have the answer.
  11. Ronj1952

    Problem with hello world

    I am getting back into programing after an extended break and the Python programing language was recommended. I'm starting with the absolute beginners tutorial and have run into the following problem with the command line. C:\users\owner\desktop>Python Helloworld.py 'Python' is not recognized as an internal or external command, operable program or batch file. I am running windows 7, Python 3.7, and I have triple checked the Environmental Variables with Variable Name: Python and Variable Value: C:\Python. Is there anything that is obvious to generate the error?
  12. Pnr4code

    Python Programming Examples

    Python Programming Examples
  13. Haseeb

    issue with function (creating functions)

    indentation should all be under the def testing_function():
  14. Haseeb

    Rock Paper Scissors Game Problem

    you are not calling the main( ) function
  15. arifin benny pristyadika

    Python Beginner Tutorial 6 - Exceptions and Loops

    def add(num1, num2): """Returns num1 plus num2.""" return num1 + num2 def sub(num1, num2): """Returns num1 minus num2.""" return num1 - num2 def mul(num1, num2): """Returns num1 times num2.""" return num1 * num2 def div(num1, num2): """Returns num1 divided by num2.""" return num1 / num2 def main(): """Allows user to run basic calculator operations with two numbers.""" validInput = False while not validInput: # Get user input try: num1 = int(input("What is number 1?")) num2 = int(input("What is number 2?")) operation = int(input("What do you want to do? 1. add, 2. subtract, 3. multiply, or 4. divide. Enter number: ")) validInput = True except: print("Invalid input. Try again.") # Determine operation if (operation == 1): print("Adding...") print(add(num1, num2)) con() elif (operation == 2): print("Subtracting...") print(sub(num1, num2)) con() elif (operation == 3): print("Multiplying...") print(mul(num1, num2)) con() elif (operation == 4): print("Dividing...") print(div(num1, num2)) con() else: print("I don't understand") def con(): valid = False while not valid: try: cont = int(input(" do you want to continue? press 1 to continue, press other than 1 to exit ")) if cont == 1: main() valid = True else: return except: return hi kevin ty for the tutorials, is my code correct? tell me if there is a mistake please !!! ty
  16. Haseeb

    Rock Paper Scissors Beginners practice

    Never done programming before. I became interested in Python and started watching kjdElectronics tutorials. I would appreciate any comments or suggestions !!! import random import time # computer random input is assigned the object def computer(comp_input): time.sleep(1) if(comp_input == 1): print('computer selected - rock') elif(comp_input == 2): print('computer selected - paper') elif(comp_input == 3): print('computer selected - scissors') # processing the result of computer and user input def operation(comp_input,user_input): if ((comp_input == 1 and user_input == 'rock') or (comp_input == 2 and user_input == 'paper') or (comp_input == 3 and user_input == 'scissors')): computer(comp_input) time.sleep(1) print('its a TIE !!') elif ((comp_input == 2 and user_input == 'rock') or (comp_input == 3 and user_input == 'paper') or (comp_input == 1 and user_input == 'scissors')): computer(comp_input) time.sleep(1) print('LOSER !!') elif ((comp_input == 3 and user_input == 'rock') or (comp_input == 1 and user_input == 'paper') or (comp_input == 2 and user_input == 'scissors')): computer(comp_input) time.sleep(1) print('WINNER !!') else: print('invalid input. try again') time.sleep(1) main() # select rock, paper or scissors def main(): restart = True while restart: comp_input = random.randint(1, 3) user_input = input('select one.. rock, paper or scissors: ') operation(comp_input,user_input) time.sleep(1) again = input('do you want to play another game? (y/n): ') if(again == 'y'): restart = True else: time.sleep(1) print('i will miss you. bye !') time.sleep(1) restart = False main()
  17. Quinn El-Nathanlee

    Introducing Arduino

    Bring it up, I have bought the starter kit (arduino starter kit ) but I don't know were to start.
  18. hello i have problem with python from series no 7" boolean loop" we lean how creat your culculate but that script i was wrote look exactl how you told when i try to run script in cmd i does't display correct answer what is numer1?22 what is number2?43 what do you want to do? Add substract multiply divide)add i dont understand
  19. Quinn El-Nathanlee

    C++

    Where do u have challenges. ..?
  20. learning_all_the_time2252

    issue with function (creating functions)

    Hello and thanks for your help. i have a function but when i execute it, it works. The issue is that it isn't supposed to work as i haven't called the function. I have it defined but haven't' called it. Yet it works. in CMD from my desktop i type the function it should fail as it hasn't been called. The failure isn't happening. When i go back into notepad++ and call the function then save. i receive the same results. it works. My issue is I don't know if I am defining and calling this function correctly. Hope that makes sense. I will post my code below and also the link from the Youtube video in which i am being instructed. it is one of yours. I am also using Python 3, not sure if that matters. My indentations are only one space over and not a tab. def testing_function(): print ("hello there") myName = input ("What is your name? ") myVariable = 'Hello' #myVar = int(input ("Enter a number: ")) #print (myName) print (myVariable , myName) if (myName == "Chamyria" ): print("Chamyria is loved by Antonio") elif(myName == "Paisleyann"): print ("You are our beloved daughter") else: print ("Antonio doesn't want you only Chamyria!") print ("Antonio doesn't want you only Chamyria!")
  21. Hey all, What topics should I study more to crack the facebook technical interview? Can you recommend what books, problems should I focus on? I'm currently practicing facebook interview questions on InterviewBIt and geeksforgeeks.
  22. damola116

    C++

    Please i realy wnt to understand the c++
  23. Hi, Installed PyCharm ok. It's a pretty complex interface. As I go through the videos, setting up new files, I have trouble just running one file at a time, creating new files, etc. Also confused about the folders, 'scratch files', and all the other features. A more in depth tour of PyCharm would be really helpful in a video. PyCharms tutorials are meant for advanced coders and use very complicated jargon. Thanks!
  24. Found it -sorry -thank you
  25. Watching these Videos, sorry if i'm late the the game... what IDE is shown in the background during the beginning of Tutorial 4? Thank you -there beginner videos are working for me. davlyo
  26. Hi guys, I cannot run the code because error: " if(operation == '+'): ^ TabError: inconsistent use of tabs and spaces in indentation" appears. Do you have an idea where I made a mistake? Here is the code: def main(): operation = input("What do you want to do?") if (operation != '+' or oroperation != '-' or operation != '*' or operation != '/'): #invalid operation print ("You must enter valid operation") else: var1 = int(input("Enter n1: ")) var2 = int(input("Enter n2: ")) if(operation == '+'): print(add(var1, var2)) elif(operation == '-'): print(sub(var1, var2)) elif(operation == '*'): print(mul(var1, var2)) else(operation == '/'): print(div(var1, var2)) main() Thanks in advance.
  27. Hi, I tried making a BMI Calculator, would love to hear your opinion about it... File: BMI Calculator.py
  28. BetaCharger

    environment variable

    I entered the path for python in my environment variable in system property but it doesn't see it. I copied and pasted it.
  1. Load more activity