• Content Count

  • Joined

  • Last visited

  • Days Won


Kevin last won the day on October 24 2018

Kevin had the most liked content!

About Kevin

  • Rank

Profile Information

  • Gender

Recent Profile Visitors

2,399 profile views
  1. $myString = "14 Char String" echo strlen($myString ); //Prints 14 The `strlen` function is what you need
  2. 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.
  3. 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
  4. 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).
  5. Kevin


    Perhaps try pressing the insert key on your keyboard? Not sure if that is the behavior you are referring to.
  6. 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
  7. 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: Presentation - Introduction to Object Oriented Programming.pdf: Python_ObjectOrientedIntro.pdf Annotated Code: Starting Code:
  8. I know what you meant for this line to do, but what does it actually do? bothand = random.randint(0,3)
  9. 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.
  10. 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!
  11. Kevin


    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!
  12. 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.
  13. See my response in earlier. It is the Same issue.