My First Computer Game...Russian Roulette in Python.
I have always been curious how software and app programs are created. Thus, I have embarked on the challenge of learning code. My goal is simply to understand a bit more about the incredible technology known as “the computer.” If I find that I am good at it and it is fun, maybe I’ll change my profession, who knows. Otherwise, it is a curiosity that I will entertain.
Of the many programming languages out there, I have settled on Python as my first language. My rationale for choosing Python is that more and more colleges (like MIT) are adopting Python as the language it teaches to its first-time programming students. Other prominent languages are Java, C, Javascript, and Ruby, to name a few.
After a few weeks of bumbling around various Python books, I have created my first program. It is a rudimentary Russian Roulette game (it is at the very end of this article). If you are learning to code or are curious about coding, try out this game. You can even modify it. I’ve see versions of this program as a dice game. I modified the code to resemble a Russian Roulette game.
Here how to use the program:
(1) Go to www.python.org/
(2) Download the newest version of Python. (I used Python 3 6.4.1 for Mac)
(3) Make sure you are able to open “IDLE”
(4) Open “IDLE”
(5) Copy and paste the Russian Roulette program shown below; save the file as Russian Roulette Game; open the file; click the “Run” tab and select “Run Module”; then press enter to spin the barrel!
Yes. After about five minutes, it gets kinda boring. But what is exciting is that you’ve actually witnessed how the words direct the computer to compute something. The “import random” language directs computer to generate a random number; while the “number=random.randint (1, 6)” language directs the computer to randomly select a number between 1 and 6. If you spend a little time looking at the code, you can sort of reverse engineer it. It takes a bit of the mystery out of programming and the computer. Programming is more accessible to the masses than most people think!
RUSSIAN ROULETTE PROGRAM IN PYTHON:
leaveprogram=0
while leaveprogram != "q":
import random
print("THIS IS A RUSSIAN ROULETTE PROGRAM. BEST PLAYED WHILE DRINKING VODKA.”)
print("Press Enter to Spin the Barrel & Test Your Courage")
input()
number=random.randint (1, 6)
if number==1:
print("[ CLICK! ]")
print("Type 'q' to quit")
leaveprogram=input()
if number==2:
print("[ CLICK! ]")
print("Type 'q' to quit")
leaveprogram=input()
if number==3:
print("[ CLICK! ]")
print("Type 'q' to quit")
leaveprogram=input()
if number==4:
print("[ CLICK! ]")
print("Type 'q' to quit")
leaveprogram=input()
if number==5:
print("[ BANG!!!! ]")
print("[ So long ]")
print("[ Comrade. ]")
print("Type 'q' to quit")
leaveprogram=input()
if number==6:
print("[ CLICK! ]")
print("Type 'q' to quit")
leaveprogram=input()
Well written
Good thoughts
Congratulations @lawonfire! You have received a personal award!
1 Year on Steemit
Click on the badge to view your Board of Honor.
Do not miss the last post from @steemitboard!
Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes
Congratulations @lawonfire! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!