Write Your First Python Game Code - Simple Multiplication Game Project

Veröffentlicht am: 27 July 2019
auf dem Kanal: Derrick Sherrill
8,080
132

Let me know if you edit this script yourself to make a better version! This was something I coded up quickly so I'm sure it can be improved. There's a lot more examples of simple python games that can be found on GitHub. Here's a repo you might find interesting:
https://github.com/grantjenks/free-py...

Hey Everyone! In this one we'll go over quite a few small topics:
Python Game logic
Python progressive difficulty
While Loops
If statements
How to use Python Random
How to use Python functools
How to use python sleep
breaking/continuing while loops

Time module: https://docs.python.org/3.7/library/t...
Random Module: https://docs.python.org/3/library/ran...
Functools: https://docs.python.org/3/library/fun...
Math Module: https://docs.python.org/3/library/mat...

Thanks so much for the support! You guys are awesome - here's your daily reminder, haha. 4,370 subscribers at the time of writing, how incredible. Thanks so much for all the kind words across all the videos, I read and try to respond to every comment I can.

*****************************************************************
Full code from the video:

import time
import functools
import operator
import random
import math

print('Number Time quiz!')
time.sleep(2)
print('Answer the multiplcation problems before time runs out!')
time.sleep(3)
print('Ready? Go!')
start_time = time.time()

score = 0

Game Logic

while True:
difficulty_setting = 2
difficulty_progression = math.floor(score/10)
overall_difficulty = difficulty_setting + difficulty_progression

numbers_list = []
for x in range(overall_difficulty):
value = random.randint(1,9)
numbers_list.append(value)

answer = functools.reduce(operator.mul, numbers_list, 1)
print('Multiple these numbers', numbers_list)

guess = int(input())

if guess == answer:
score = score + (1 * overall_difficulty)
continue

else:
print('Game over! The answer was', answer)
elapsed_time = time.time() - start_time
print('Your score was', score, 'In only', elapsed_time)
break

https://github.com/Derrick-Sherrill/D...
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
https://github.com/Derrick-Sherrill/D...

Check out my website:
https://www.derricksherrill.com/

If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!

Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!


Auf dieser Seite können Sie das Online-Video Write Your First Python Game Code - Simple Multiplication Game Project mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Derrick Sherrill 27 July 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 8,080 Mal angesehen und es wurde von 132 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!