Popular Content

Showing most liked content since 11/12/2017 in all areas

  1. 1 point
    This tutorial covers the instillation of the latest version of Python 3 and instillation and setup of the Free JetBrains PyCharm IDE. After watching this video you will know how to run your very first python script (Hello World). This video series is ideal for individuals looking to learn their first programming language or individuals looking to learn python as another programming language. Download Links: Python3: https://www.python.org/downloads/ PyCharm (Community): https://www.jetbrains.com/pycharm/download/#section=windows Post questions and comments specifically related to this video below.
  2. 1 point


    hey, I am new to programing and i have been messing around with python. i am trying to make a High Low guessing game. my goal is to have the user guess until they get it right, then once they guess it right it will restart or end. here is my code. sorry that it is messy. import random """cpu picks a random number""" num1 = (random.randint(1,10)) """helping keeping track of number of guesses""" """counter to keep track of number of guesses""" num2 = 0 "runs guessing game" def guessing_game(num2): goodgusse = False """used if user puts in wrong input""" validInput = False while not validInput: "gets user to pick a number between 1 and 10" while goodgusse == False: try: guess = int(input("what number am I thinking of between 1 and 10?")) num2 +=1 if (guess > (num1)): print ("too high") elif (guess < (num1)): print("too low") elif (guess == (num1)): print("you got it ") print("it took you " + str(num2) + (" times to get it right.")) print("it was " + str(num1)) break except ValueError: """ user is told they have to reenter the number.""" print("Invalid Input, try again.") guessing_game(num2)
  3. 1 point


    Made my first program using KJDElectronics' video tutorials of Python! This is the edited and cleaned up version i made after reading some advice about splitting up functions so that they can become more usable. Really happy with it and I'm still waiting on some more constructive criticism and ways to improve it! Here it is! """Calculator""" # Modules: import time # used as an illusion of loading for effects import random # used for random numbers in random_operation function import sys # used to exit program when needed # Operations: def add(num1, num2): # Defines addition return num1 + num2 def sub(num1, num2): # Defines subtraction return num1 - num2 def mul(num1, num2): # Defines multiplication return num1 * num2 def div(num1,num2): # Defines division try: return num1 / num2 except ZeroDivisionError: # Handles division by zero print("Division by zero cannot be done. Returning zero...") return 0 def exp(num1, num2): # Defines exponentiation return num1 ** num2 # Run operation function: def run_operation(operation, num1, num2): # Determine operation if operation == int("1"): print("Adding...") time.sleep(1) print(num1, "+", num2, "=", add(num1, num2)) elif operation == int("2"): print("Subtracting...") time.sleep(1) print(num1, "-", num2, "=", sub(num1, num2)) elif operation == int("3"): print("Multiplying...") time.sleep(1) print(num1, "*", num2, "=", mul(num1, num2)) elif operation == int("4"): print("Dividing...") time.sleep(1) print(num1, "/", num2, "=", div(num1, num2)) elif operation == int("5"): print("Raising to the power...") time.sleep(1) print(num1, "^", num2, "=", exp(num1, num2)) else: print("I don't understand") time.sleep(1) # Random operation function def random_operation(operation): for loop in range(4): # repeats random calculations 4 times valid_input = False while not valid_input: # while loop for invalid inputs try: operation = (input("What would you like me to do? add, subtract, multiply, divide, or " "raise to the power?...")) valid_input = True except ValueError: print("I don't understand...") time.sleep(1) # Defines random calculations random_num1 = random.randint(1, 100) random_num2 = random.randint(1, 100) if operation == str("add"): print("Randomizing") time.sleep(1) print(random_num1, "+", random_num2, "=", add(random_num1, random_num2)) time.sleep(1) elif operation == str("subtract"): print("Randomizing") time.sleep(1) print(random_num1, "-", random_num2, "=", sub(random_num1, random_num2)) time.sleep(1) elif operation == str("multiply"): print("Randomizing") time.sleep(1) print(random_num1, "*", random_num2, "=", mul(random_num1, random_num2)) time.sleep(1) elif operation == str("divide"): print("Randomizing") time.sleep(1) print(random_num1, "/", random_num2, "=", div(random_num1, random_num2)) time.sleep(1) elif operation == str("raise to the power"): print("Randomizing") time.sleep(1) print(random_num1, "^", random_num2, "=", exp(random_num1, random_num2)) time.sleep(1) else: print("I don't understand") time.sleep(1) print('\nPLEASURE CALCULATING WITH YOU.') time.sleep(1) print('GOODBYE...') time.sleep(1) sys.exit() # Exits program # Main calculator function: def main(): user_continue = True while user_continue: # Loops if user would like to restart program valid_input = False while not valid_input: # Loops if user enters an invalid input. Avoids error try: # Acquire user input num1 = int(input("What is number 1?...")) num2 = int(input("What is number 2?...")) operation = int(input("What would you like to do? 1. Addition, 2. Subtraction, 3. Multiplication, " "4. Division, 5. Exponentiation... Choose a number...")) valid_input = True except ValueError: # Handles any value errors print("invalid input, please try again...") time.sleep(1) run_operation(operation, num1, num2) time.sleep(1) # Ask if user wants to do random calculations or exit: restart_random = (str(input("Would you like to make more calculations? (y) for yes, anything else for no..." "\n OR would you like a random calculation?...(r) for random calculations then " "exit...anything else for no..."))) if restart_random != "y" and restart_random != "r": print("PLEASURE CALCULATING WITH YOU!") time.sleep(1) print("\nGOODBYE!") time.sleep(1) user_continue = False elif restart_random == "r": time.sleep(1) random_operation(operation) # intro-like sequence print('\n\n Calculator\n\n') time.sleep(1) print(' ---LOADING---\n') time.sleep(1) print('HI. I AM YOUR PERSONAL CALCULATOR BEEP BOOP. \n WHAT WOULD YOU LIKE ME TO CALCULATE?..\n') time.sleep(1) # call main function to start program main() # Turns my program into a module capable of being imported: if __name__ == '__calculator__': main() calculator.py
  4. 0 points
    This tutorial covers an introduction to writing clean code. This video focuses on cleaning up our existing calculator program to make it more robust and easier to read. This video also introduces the for loop, loop control keywords "break," "continue" and introduces the "import" keyword to demonstrate time.sleep() and random.randint(). After watching this video you should be ready to start on the two challenges posed at the end of the video. Challenge 1: Random Calculator Modify the calculator program to use randint to run random calculations. Make this as random as you want so be creative!! Feel free to also use time.sleep() to give your program a more autonomous feel to it. Bonus points if you incorporate a for loop and loop control keywords. Remember to use the clean code strategies discussed in this video; if you have big blocks of code that look hard to read then try to fix it. Challenge 2: Rock, Paper, Scissors Game This idea was originally created by Zibzo and what he is posted here. Try to write clean code and note that what was posted by Zibzo has room for improvement given what we learned in this video.
  5. 0 points
    Hi, I'm having the same issue as Logmein. I've tried this 4-5 times but do not see what error I'm making when installing (or select to create the environmental variable). Related, what is "PyCharm"? when would I use this?