Python Tutorial 1 – Creating a simple game.

Hacking Demo: https://www.youtube.com/watch?v=JTbqvgED_y0

New Updated Code Here: (WITH JAVA COMPARISON) MUCH WATCH!
https://www.youtube.com/watch?v=g70WJVsTyQE

Want to support my channel?
https://www.patreon.com/codecommand
I’ll be eternally grateful

In this video I go through the basics of Python by showing you how to create a simple guess the number game.

Creating this game with a GUI: https://www.youtube.com/watch?v=sx0aUvHz3cI

Please subscribe & like for more content, tutorials and tips!

**********************************

Download Python: https://goo.gl/YkZpjQ
Download Pycharm: https://goo.gl/zpcXQd
CODE FOR THE GAME HERE (updated 2018):
https://goo.gl/vMtAVK
***********************************

Connect With Me:
Twitter: https://goo.gl/HssDVu
Website: www.codeoncommand.com

***********************************

Comments

CodeCommand says:

new link with much better code: https://goo.gl/vMtAVK

Jacob Sexson says:

there is no end to your game. when you run it in the python shell it just quits after you guess the number correctly. Roblox guy in your comments had a finish for it

Anna Aiza says:

can u creating a trivia game?

Latch06 says:

How did you learn to do this?

Damon Martin says:

That’s a nice way of teaching the classic binary search algorithm props to you 😉

Nex Rasta says:

I know SQL and not sure what’s next but you made it look like feasible. Awesome video!

Captain_Pie says:

That was much more helpful thanks alot! Now I can begin creating my own game!

مني جامع says:

Oh like and share every one please i want 1000 subscribe

tech cube says:

what’s fuck

Poisonous says:

His voice is so damn pleasant.

GamingLizard says:

what version is this?

Work Smart says:

bro there are two versions of pycharm
which one should i download pls

DOG 4399 says:

the random module isnt callable help plz

Roblox Adventures With Timmy says:

That didn’t work… but this did
import random

attempts = 1
secret_number = random.randint(1,100)
isCorrect = False
guess = int(input(“Take a guess: “))

while secret_number != guess and attempts < 6: if guess < secret_number: print("Higher...") elif guess > secret_number:
print(“Lower…”)
guess = int(input(“Take a guess: “))
attempts += 1

if attempts == 6:
print(“nSorry you reached the maximum number of tries”)
print(“The secret number was “,secret_number)

else:
print(“nYou guessed it! The number was ” ,secret_number)
print(“You guessed it in “, attempts,”attempts”)

input(“nn Press the enter key to exit”)

AchZozi says:

Why repeat yourself with the if statements, its better to have them all inside the loop

Porg Gang says:

CAN YOU DONA TIC TAC TOE GAME?

Bambi says:

“NameError: name ‘guess’ is not defined” any ideas on how to fix this?

Mert Usta says:

i copied this for my homework

NoNameGaming says:

Why do you sound nervous?

Warfan 1815 says:

R.I.P Headphone users, and maybe his mic

Eri Airlangga says:

I’m new to open-source languages. What IDE can you recommend?

Anton Podolnyy says:

You sound like Maurice from IT Crowd.

ElfsTV says:

what script do you use for running it on atom? like I tried a lot of them and none worked for me

Marti Borisov says:

Rest in piece Snowball we’ll all miss you , for real tho nice tutorial enjoyed it a lot , it was fun coding a long with you since its my 1st time doing so in python , had me dying when you dropped the mic tho 😀

Adam Saleh says:

is this guy from Liverpool?/ are you from liverpool mate?
Bcuze your accent is scouse!

Ahmad M says:

Its not letting me run the code on pycharm. Everytime i click run, it gives me an option to edit configuration. Would appreciate some help. Newbie here. Thanks.

Ryan storytoons says:

2018 but this is better:

print(“Hi, what is your name?”)
name = input(“>>”)
print(“Hello ” + name + “!”)

Ziaur Rahman says:

Good example

Glen Smith says:

Cool… it worked..my first Python program 🙂 Cheers CodeCommand!.

Pengu says:

What editor is this??

Syntela says:

What is the for in the last line of code.

Atte Immonen says:

Why can’t I run the code on python 3.6.4? Im getting syntax errors, shitload of indentation errors and the inputs are not working properly, same thing happens if I make my own code or copy any of yours.

Edit: It actually works in pycharm, but why can’t I copy it straight into python?

Calisthenics9110 says:

are you a scouser?

Captain_Pie says:

This wasn’t helpful at all, I’m disappointed, This was supposed to be a tutorial.

jonathan signori says:

hahahaha!!moi aussi c quand y a dropper le mic Loll

Ttornado 17 says:

Wow… I’m a very beginner and i would like to see more of your videos 🙂

Mehrdad Gh says:

On your line 22 guess is highlighted. When I put in the same code when it reaches there it gives me an error and it says that guess is not defined. Help please????

DigitalNekkoArt says:

I think, gamemaker is much better

KING2672 says:

import random

number = random.randint(1, 10)
tries = 1
win = False # setting a win flag to false

name = input(“Hello, What is your usernmae?”)

print(“Hello”, name + “.”, )

question = input(“Would you like to play a game? [Y/N] “)
if question == “N”:
print(“oh..okay”)

if question == “Y”:
print(“I’m thinking of a number between 1 & 10 “)
while not win: #while the win is not true, run the while loop. we set win to false at the start therefore this will always run.
guess = int(input(“Have a guess: “))
tries = (tries)+1
if guess == number:
win = True # set win to true when the user guesses correctly.

elif guess < number: print("Guess Higher") elif guess > number:
print(“Guess Lower”)

if win: # if win is true then output message
print(“Congrats, you guessed correctly. The number was indeed {}”.format(number))
print(“It took you {} tries”.format(tries-1))

how about this?

Sandzz says:

i thought you gonna show us how to make next assassins creed…but this is cool too

Matt James says:

This is awesome! Thanks so much man! Keep up the videos!

Leif A says:

Dude I actually love how the video flowed, seeing you fix mistakes most people might casually make really helps understand the tediousness of code even when really simple. Thanks for the video man great job I was laughing my ass off at the if < if > part.

Puspraj Singh says:

see this sequence..do you think is it correct to ask for a guess if a user has selected ‘n’ at the start? Just a gentle query 🙂

Hello, What is your username?bunty
Hello bunty.
Would you like to play a game? [Y/N] n
oh..okay
Have a guess: 4
Guess Lower
Have a guess: 3
Guess Lower
Have a guess: 2
Congrats, you guessed correctly. The number was indeed 2
it had taken you 4 tries

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!