Kevin

Administrators
  • Content count

    213
  • Joined

  • Last visited

  • Days Won

    25

Kevin last won the day on October 24

Kevin had the most liked content!

About Kevin

  • Rank
    Administrator

Profile Information

  • Gender
    Male

Recent Profile Visitors

1,800 profile views
  1. 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.
  2. Kevin

    Facing problem with functions

    Have you saved the file? That code is fine. Tested and got the following output: What is num1?1 What is num2?1 2 0 1 1.0 Process finished with exit code 0
  3. Kevin

    Facing problem with functions

    The input function ALWAYS returns a string. You are trying to do math on a string which is only allowed sometimes (you can see me discover something strange in one of the videos). You need to call the int function to convert from a string to an integer (parse).
  4. Kevin

    Question

    Perhaps try pressing the insert key on your keyboard? Not sure if that is the behavior you are referring to.
  5. Sure! See the code below with comments and some changed names to make it easier to understand. My bad on that originally. def main(): print(aGlobalVariable) def myPrintFunction(somethingToPrint): print(somethingToPrint) # This will not work because aGlobalVariable has not been defined yet #main() # Global variable. Typically defined at the top of the file but does not need to be. That is best practice aGlobalVariable = "This is a global variable." # Call the main function. This will print aGlobalVariable main() # Directly call the print function. This will print aGlobalVariable again to illistrate it is in fact global print(aGlobalVariable) # Define another variable otherVariable = "Something else" # This will print otherVariable by calling our myPrintFunction that then calls the print function. myPrintFunction(otherVariable) Let me know if you need me to clarify anything specifically. Kevin
  6. This tutorial covers an introduction to Object Oriented Programming in Python. After watching this video you should feel comfortable creating a basic class. This includes a constructor (__init__ function), and class methods. You should feel comfortable using parameters in a class constructor as well as class methods. Class methods should be able to access class properties using self. You should also understand that the 'self' variable needs to be passed into all methods within a class in python. Files: Starting Code: Start_Here.py rps.py: rps.py rps_annotated.py: rps_annotated.py Presentation - Introduction to Object Oriented Programming.pdf: Python_ObjectOrientedIntro.pdf Annotated Code: Starting Code:
  7. Kevin

    Rock Paper Scissors Beginners practice

    I know what you meant for this line to do, but what does it actually do? bothand = random.randint(0,3)
  8. Do you have another call to main() at the end of the function by any chance? Other than that I don't see anything that would cause that... Can you post your entire file? When posting code use the button at the top that looks like this "< >". That is the code button. You can paste your code in there and set the language to python in the bottom right. Makes it much easier to help troubleshoot.
  9. I plan to have the next video published by the end of the day on Saturday. Once its published there will be a thread here. Also make sure to subscribe on YouTube!
  10. Kevin

    Calculator

    Looks great! Your calculator() function is a bit lengthy. Think about different ways you can break up the code into smaller functional components. The smaller you make functions (by small I mean functions that do a single well defined thing) then the more you can reuse those functions. Great work!
  11. Kevin

    Equality Comparison doing opposite

    This is because the input function returns a string type. For example, if you type '25' into the console the variable myVar = '25' and not myVar = 25. There is a difference between a string (text) and a number (integer). Text can be a number but you have to tell the computer to convert it first. You need to use the int() function to parse your string into an integer. Change your code to this to see what is going on. print("Hello World") myName = input('What is your name?') myVar = input('How old are you?') print(myVar) myVar = int(myVar) print(myVar) print(myName) if(myName == "Kyle" and myVar == 25): print("Hello Kyle") else: print("Hello World") Note this will crash if you enter anything other than a number for your age.
  12. Kevin

    Program did not run correctly

    See my response in earlier. It is the Same issue.
  13. Kevin

    why am i wrong

    Code looks code good but nothing happening is very different than getting an error. If nothing is happening then your code probably is not running at all. If you code is running and you see "exit code 0" in the console that means your program is running and that is something. It looks like you may have missed calling your main function at the end of the file. This comment I posted on YouTube sums up what your program does withthout calling the main function:
  14. What the video in the first post in this thread. PyCharm is an IDE (integrated development environment). The video explains how to setup and install PyCharm. That will at least get you started using python and you can save your environment variable issues for another day.