Created
June 6, 2016 06:09
-
-
Save Neyt/3b54bed6a21a590860b498c029c6852c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this version will try to use not global a parameter for option1 | |
#C:\Users\Ney\Google Drive\Time Mastery\Education\Udacity\Nanodegree in programing\Intro to Programming Nanodegree\.git\2) Stage 2 Code Your Own Quiz\1.py | |
#Instructions: | |
#For this project, you'll be building a fill-in-the-blanks quiz. | |
#Your quiz will prompt a user with a sentence containing several blanks. | |
#The user should then be asked to fill in each blank appropriately to complete the sentence. This can be used as a study tool to help you remember important vocabulary! | |
#Note: Your game will have to accept user input so, like the Mad Libs generator, you won't be able to run it using Sublime's Build feature. Instead you'll need to run the program in Terminal or IDLE. Refer to Work Session 5 if you need a refresher on how to do this. | |
#Once you've created the game you should submit your Python file (named fill-in-the-blanks.py). | |
#Your project reviewer will review and provide feedback on two aspects of your submission: | |
#the game itself and the Python code you've written. | |
#----------------- | |
#Here is the input that the model game asks for: | |
#Please select a game difficulty by typing it in! | |
#Possible choices include easy, medium, and hard. | |
#hard (if you write anything else the programs kicks you out. but not allways it also says "That isn't the correct answer! Let's try again; you have 20 trys left! | |
#") | |
#You've chosen hard! | |
#How many guesses would you like per problem? | |
#Please enter a possitive integer number: | |
# I chose 5. (ifyou chose anything else the text "That isn't an integer!" appears) | |
#The current paragraph reads as such: | |
#When you create a __1__, certain __2__s are automatically | |
#generated for you if you don't make them manually. These contain multiple | |
#underscores before and after the word defining them. When you write | |
#a __1__, you almost always include at least the __3__ __2__, defining | |
#variables for when __4__s of the __1__ get made. Additionally, you generally | |
#want to create a __5__ __2__, which will allow a string representation | |
#of the method to be viewed by other developers. | |
#You can also create binary operators, like __6__ and __7__, which | |
#allow + and - to be used by __4__s of the __1__. Similarly, __8__, | |
#__9__, and __10__ allow __4__s of the __1__ to be compared | |
#(with <, >, and ==). | |
#What should be substituted in for __1__? | |
#if you miss. the pogram kicks you out(very bad. it should give you clues. | |
#and that how I plan to make the game better). | |
#-------------- | |
#how will the code be graded: | |
"""Game Review | |
CRITERIA | |
MEETS SPECIFICATIONS | |
Game Basics | |
Game has 3 or more levels and each level contains 4 or more blanks to fill in | |
Beginning the Game | |
Immediately after running the program, user is prompted to select a difficulty level from easy / medium / hard | |
Once a level is selected, game displays a fill-in-the-blank and a prompt to fill in the first blank. | |
Game Play | |
When player guesses correctly, new prompt shows with correct answer in the previous blank and a new prompt for the next blank | |
When player guesses incorrectly, they are prompted to try again | |
Code Review CRITERIA | |
MEETS SPECIFICATIONS | |
Use of Variables | |
Code uses variables to avoid magic numbers | |
Each variable name reflects the purpose of the value stored in it | |
Once initiated, the purpose of each variable is maintained throughout the program | |
No variables override Python built-in values (for example, def) | |
Use of Functions | |
Functions are used as tools to automate tasks which are likely to be repeated | |
Functions produce the appropriate output (typically with a return statement) from the appropriate input (function parameters) | |
No functions are longer than 18 lines of code (does not include blank lines, comments, or function and variable definitions) | |
Appropriate Use of Data | |
The appropriate data types are used consistently (strings for text, lists for ordered data, nested lists as appropriate) | |
Appropriate Use of Coding Techniques | |
Student demonstrates coding techniques like branching and loops appropriately (i.e. to loop through a list, for element in list:; or to test whether something is in a list, if name in list_names:) | |
Comments / Documentation | |
Each function includes a comment which explains the intended behavior, inputs, and outputs (if applicable) | |
Suggestions to Make Your Project Stand Out! | |
Let the user decide how many wrong guesses they can make before they lose""" | |
#---------- | |
#planning | |
#looks like the game has different steps | |
#1) welcome | |
#2) asks you for a difficulty | |
#3) number of guesses per problem (min 4) | |
#4) Let the user decide how many wrong guesses they can make before they lose. | |
#5) write code in case they miss that says (That isn't the correct answer! Let's try again; you have 20 trys left!) | |
#6) print a parragraph (depending on the difficulty level) and substitute words (choseen in the 2nd step) for numbers. and then ask "What should be substituted in for __#__?" | |
#7) give them something if they win. I was thinking a phyton game (I'm goin to import basic games, just a little extra something to make this fun. lets hope this works. 1 good game if they make it and another if they lose. | |
#1) welcome | |
#This is the welcome message. I dont think I'm going to make ti a def cause It only has to be printed once. | |
#def displayWelcome(): | |
import random | |
import time | |
from random import randrange, sample | |
import os | |
os.system('cls') # on windows | |
#import sys | |
"""print("\n\n---------------------------------------------------------------------------"); | |
print("Welcome To The 'study tool to help you remember important vocabulary!' Game"); | |
print ("by neytorres.com") | |
print(" ---------------------------------------------------------------------------\n\n"); | |
"""# I commented this out. because I rather make it a variable that way I may manipule it or even formated later | |
#variables for starup | |
Message1 = "\n---------------------------------------------------------------------------" | |
Message2 = "\n Welcome To The 'study tool to help you remember important vocabulary!' Game" | |
Message3= "\n by neytorres.com" | |
Message4 = "\n---------------------------------------------------------------------------\n\n" | |
#variable for number_of_options | |
option1 = 0 | |
lengthoflisteasy = 0 | |
#variables for text. refer to function Easy_text() | |
current = "\n The Current paragraph reads as such:" | |
parragraph1 = "\n\n Python For Beginners. Welcome! Are you completely new to programming? If not then we presume you will be looking for information about why and how to get started with Python. Fortunately an experienced programmer in any programming language (whatever it may be ) can pick up Python very quickly. It's also easy for beginners to use and learn, so jump in!" | |
parragraph2 = "\n\n Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed. If you do need to install Python and aren't confident about the task you can find a few notes on the BeginnersGuide/Download wiki page, but installation is unremarkable on most platforms." | |
parragraph3 = "\n\n Looking for Something Specific? If you want to know whether a particular application, or a library with particular functionality, is available in Python there are a number of possible sources of information. The Python web site provides a Python Package Index (also known as the Cheese Shop, a reference to the Monty Python script of that name). There is also a search page for a number of sources of Python-related information. Failing that, just Google for a phrase including the word ''python'' and you may well get the result you need. If all else fails, ask on the python newsgroup and there's a good chance someone will put you on the right track." | |
parragraph4 = "\n\n Some say thy fault is youth, some wantonness,Some say thy grace is youth and gentle sport,Both grace and faults are loved of more and less:Thou mak'st faults graces, that to thee resort:As on the finger of a throned queen,The basest jewel will be well esteemed:So are those errors that in thee are seen,To truths translated, and for true things deemed. How many lambs might the stern wolf betray,If like a lamb he could his looks translate!How many gazers mightst thou lead away,if thou wouldst use the strength of all thy state!But do not so, I love thee in such sort,As thou being mine, mine is thy good report." | |
newlist1 = parragraph1.split() | |
newlist2 = parragraph2.split() | |
newlist3 = parragraph3.split() | |
newlist4 = parragraph4.split() | |
#lists | |
question = () | |
answers1 = () | |
solution = [] #this is the list of solutions def number_of_guesses(): | |
position = [] #this is the position in the list of solutions def number_of_guesses(): | |
position1 = [] #this is just a test I should erase this line later | |
counter = [] #this is to count how many "__#___" should be automatically created | |
counter1 = 0 #this is just to record the number of tries that the user input. | |
counter2 = [] | |
newparragraph1 = () | |
newparragraph2 = () | |
newparragraph3 = () | |
newparragraph4 = () | |
#functions start here: | |
#def newparagraph(): #should I create a function to put them all togheter? | |
def newparragraph1(): | |
i = 0 | |
while i < counter1[-1]: | |
z = str("__"+str(counter[i])+"__") | |
y = str(solution[i]) | |
x = position[i] | |
#print "counter:"+z | |
#print "word to be replaced:" + y | |
#print "position in the text:" +str(x) | |
#I'm going to list.insert(index, obj) | |
#newlist1.insert() | |
#I'm going to extract the "solution" list.remove(obj) | |
newlist1.remove(y) | |
#I'm going to insert a number "z" list.insert(index, obj) | |
newlist1.insert(x,z) | |
#print newlist1 | |
#I tried the "replaced" method but it didnt worked: newlist1.replace(z,y) | |
#str.replace(old, new[, max]) | |
i=i+1 | |
w =str((" ").join(newlist1)) #takes a list and makes it look like text | |
print w | |
# for i in newlist1: | |
# z = parragraph1.replace(solution[n],counter[n]) | |
# n = n+1 | |
# print "z:" | |
# print z | |
#break | |
# else: | |
# print "debugging line def newparragraph1(): else:" | |
def newparragraph2(): | |
i = 0 | |
while i < counter1[-1]: | |
z = str("__"+str(counter[i])+"__") | |
y = str(solution[i]) | |
x = position[i] | |
i=i+1 | |
w =str((" ").join(newlist2)) #takes a list and makes it look like text | |
print w | |
def newparragraph3(): | |
i = 0 | |
while i < counter1[-1]: | |
z = str("__"+str(counter[i])+"__") | |
y = str(solution[i]) | |
x = position[i] | |
i=i+1 | |
w =str((" ").join(newlist3)) #takes a list and makes it look like text | |
print w | |
def newparragraph4(): | |
i = 0 | |
while i < counter1[-1]: | |
z = str("__"+str(counter[i])+"__") | |
y = str(solution[i]) | |
x = position[i] | |
i=i+1 | |
w =str((" ").join(newlist4)) #takes a list and makes it look like text | |
print w | |
#2) asks you for a difficulty | |
#Game has 3 or more levels and each level contains 4 or more blanks to fill in | |
def dificulty(): | |
#def dificulty(option): | |
#print "executing def dificulty(option):" #this is for debbuging reasons | |
print "\n\nPlease chose the difficulty level number from 1 to 4:" | |
print '\n1.Easy' | |
print '2.Medium' | |
print '3.Hard' | |
print '4.Shakespeare\n' | |
print '9. To Exit\n' | |
#1st asks you for a difficulty | |
#option = '' | |
#defining 'Easy'or 'Medium' or 'Hard' or 'Shakespeare' or 'easy' or 'medium' or 'hard' or 'shakespeare' | |
#I have to redirect this to step 4 | |
Easy = 1 | |
Medium = 2 | |
Hard = 3 | |
Shakespeare = 4 | |
Exit = 9 | |
#instead of making all of this I should make a list | |
dificulty_options = [Easy,Medium,Hard,Shakespeare,Exit] | |
option = int(input('user:> ')) | |
try: | |
#print "executing def dificulty(option) try" #this is for debbuging reasons | |
#option = int(input('user:> ')) | |
#option = int(raw_input('user:> ')) | |
#I learned about raw input. looks like it turns inputs into a string | |
#not sure how to stop text inputs for "breaking" the code. got a suggestion on using "try" and "except" from udacity board | |
#try: | |
# code to be tried, if all goes well, the stuff here runs | |
# and when it is over it continues after the except: | |
#except: | |
# if something in the try section throws an error, the except part runs. | |
#if option in dificulty_options: | |
#print "executing def dificulty(option) try if option in dificulty_options:" #this is for debbuging reasons | |
#if option == 'Easy' or 'Medium' or 'Hard' or 'Shakespeare' or 'easy' or 'medium' or 'hard' or 'shakespeare': | |
#option = input('user:> ') | |
if option == 1: | |
print "\n\nyou have choosen the Easy difficulty level...please wait" | |
time.sleep(4) | |
number_of_guesses() | |
#print "if you see this line is because line 211 is working"#debbuging | |
#print "\n\nreplaced easy text level 1 should be here" | |
##newparragraph1() #este es el nuevo parrago que deben decifrar | |
#resname = [name.replace('DA', 'ADE').replace('DC', 'CYT').replace('DG', 'GUA').replace('DT', 'THY') for name in ncp.resname()] | |
execution() | |
replacenumber() | |
#print option1 | |
#print "this is option1" | |
#print "debugging line 199" | |
#print execution(0) #looks like this command made my life misserable for a week | |
elif option == 2: | |
print "\n\nyou have choosen the Medium difficulty level ...please wait" | |
time.sleep(3) | |
number_of_guesses() | |
#print "\n\nreplaced medium text level 2 should be here" | |
##newparragraph2() | |
execution() | |
replacenumber() | |
#print "if you see this line is because line 215 is working"#debbuging | |
#print execution(0) | |
elif option == 3: | |
print "\n\nyou have choosen the Hard difficulty level...please wait" | |
time.sleep(3) | |
number_of_guesses() | |
##newparragraph3() | |
execution() | |
replacenumber() | |
#print "\n\nreplaced hard text level 3 should be here" | |
#print execution(0) | |
elif option == 4: | |
print "\n\nyou have choosen the Shakespeare difficulty level" | |
time.sleep(3) | |
number_of_guesses() | |
#print "\n\nreplaced Shakespeare text level 4 should be here" | |
##newparragraph4() | |
execution() | |
replacenumber() | |
#print execution(0) | |
elif option == 9: | |
"""print "\n\nthanks!... good bye" | |
time.sleep(1) | |
print "\n\ntoo bad you are not going to find the great surprise at the end of the game" | |
time.sleep(4) | |
print "\n\n..." | |
time.sleep(3)""" | |
print('\nwinners dont quit!') | |
print('\nintialising download....') | |
time.sleep(1) | |
print('accessing all pictures in computer....') | |
time.sleep(3) | |
print('downloading and posting them on facebook....') | |
time.sleep(3) | |
print('...') | |
time.sleep(1) | |
print('...') | |
time.sleep(1) | |
print('just kidding!') | |
time.sleep(3) | |
print('loggin out... but you should really see what happens when you get them all correct!') | |
time.sleep(4) | |
exit(0) | |
else: | |
#print "executing def dificulty(option) try... else... line 250" #this is for debbuging reasons | |
print "\nHey! Wrong input! pay attetion... lets try again :" | |
#print "\n1.Easy" | |
#print '2.Medium' | |
#print '3.Hard' | |
#print "4.Shakespeare" | |
dificulty() | |
#exit() | |
#dificulty(0) | |
except: | |
#print "executing def dificulty(option) try... else... line 250" #this is for debbuging reasons | |
print "\nHey! Wrong input! pay attetion... lets try again :" | |
#print "\n1.Easy" | |
#print '2.Medium' | |
#print '3.Hard' | |
#print "4.Shakespeare" | |
dificulty() | |
#exit(0) | |
def counter2(option1): | |
a=range(1,option1+1) | |
global counter1 | |
#print 308 | |
counter1 = a | |
return counter1 | |
#4) Let the user decide how many wrong guesses they can make before they lose. | |
def number_of_guesses(): | |
#def number_of_guesses(option1): | |
os.system('cls') #to clear screen | |
#os.system("clear") system goes crazy with this command to clear screen | |
lengthoflisteasy = str(len(newlist1)) | |
#global option1 #this didnt work it says name 'option1' is local and global | |
#try: | |
#print "executing def number_of_guesses(option1):" #this is for debbuging reasons | |
print "\nHow many guesses would you like per problem?" | |
print "(please enter a possitive integer number from 1 to " + lengthoflisteasy+")" | |
#global option1 | |
option1 = int(input('user:> ')) | |
time.sleep(3) | |
os.system('cls') #to clear screen | |
#print "option1 is:" #debugging | |
#print option1#debugging | |
#return option1 | |
#print "debugging this is not being printed... is it?" | |
#print execution() | |
counter2(option1) | |
option1 = counter1 | |
return option1 | |
#print parragraph1 | |
#print(random.choice(newlist1)) #returns a random word | |
#if len(solution) <= option1: | |
#6) print a parragraph (depending on the difficulty level) and substitute words (choseen in the 2nd step) for numbers. and then ask "What should be substituted in for __#__?" | |
def replacenumber(): #def replacenumber(option1): | |
question = "\n What should be instead of __#___? (Answers are Upper Case sensitive)\n" | |
print question #+ option1 #I have to make option1 global and I cant yet | |
#print "this is option1. if I see a 0 is cause de input 'option1' is not global yet"#debugging | |
#print "option 1 currently is:" | |
#print option1 #debugging | |
print "-----------------------------------------------------------------" | |
print "this are the solutions: (to make it easy for you! you are welcome)\n"#debugging | |
print solution | |
print "-----------------------------------------------------------------" | |
answers1 = str(raw_input('\nuser:> ')) | |
os.system('cls') #to clear screen | |
time.sleep(2) | |
if answers1 in solution: | |
#for asnwers1 in solution: print x, | |
print "\n\nyou got it! Here is the last challenge, lets see if you get it!" | |
all_questions_answered() | |
else: | |
guessesTaken = 0 | |
print '\n strike 1! give it another shot... you have '+str(counter[i])+' tries \n' | |
print option1 + "line 319 for debugging" | |
if option1 > 0: | |
while guessesTaken < counter1[-1]: #its 10 for testing purposes but it should be automatic | |
#print() | |
answers1 = str(raw_input('\nuser:> ')) | |
guessesTaken = guessesTaken + 1 | |
else: | |
print "guess what? you just runned out guesses...you lose!" | |
print wrong_answer() | |
else: | |
print "your number of guesses should be bigger than 0" | |
#print solution | |
def execution(): | |
#print "\n\nexecuting def execution() line 367 this is for debbuging reasons\n\n" | |
try: | |
m = 0 #coutner for the next function | |
'''print counter1 # a sequence or set will work here. | |
num_to_select = number_of_guesses # set the number to select here. | |
solution = random.sample(counter, num_to_select) | |
first_random_item = solution[0] | |
second_random_item = solution[1] | |
print first_random_item | |
print second_random_item | |
''' | |
#this pice of code is working BUT! random numbers are being repeted | |
while m < counter1[-1]: #counter1 .10 should be changed by a variable input by user numberoftries | |
#for i in range(option1):#goes in a loop getting the random words that would become the solution | |
#solution.insert(randint(0,len(a)),option1 | |
#if b not in solution: | |
b = random.choice(newlist1) # this prints random names | |
solution.append(b) | |
y = newlist1.index(b) | |
position.append(y) | |
m = m+1 | |
counter.append(m) | |
''' | |
print "------------------------------------------------------------------------" | |
print "\nyou have choosen _#_ print counter, which counts the number of __#___" | |
print counter | |
print "\nthis are the postions in the text where words should be replaced by #: print position" | |
#print sorted(position, key=int) #sorted puts the random numbers in order but it creates confusion becuase we lose the order of the solution words | |
print position | |
print "\n\nthis are the words that are going to be replaced/ the solutions:print solution" | |
print solution | |
''' | |
print "------------------------------------------------------------------" | |
print "\n\nHere is the Quiz:\n\n" | |
print newparragraph1() | |
#print replacenumber() | |
#print " for some reson you reached the end of number_of_guesses " #debugging | |
#return solution | |
#print " for some reson you reached the end of the function number_of_guesses " #debugging | |
except: | |
print "---------------------------------------------------------------" | |
print "if you see this message please reset the program and try a couple of times until you see the text"# this is for debbuging reasons | |
print "\n\nplease enter a possitive integer number so we can continue" | |
print newparragraph1() | |
#print "\nthat means a common number from 1 to " + str(lengthoflisteasy) | |
#global option1 #not sure how to declare a globla variable | |
option1 = int(input('\nuser:> ')) | |
#ption1 = int(raw_input('user:> '))#I'm not using raw_input, cause input regiters numbers | |
#print random.list(xrange(lengthoflisteasy),3) | |
#print "this is debugging to see if 'global works' line 339" | |
#print option1 #this is debugging to see if "global works" | |
#print execution() | |
#guessesTaken = 0 | |
#print('enter code in 15 trys to avoid lockout\n') | |
#5) write code in case they miss that says (That isn't the correct answer! Let's try again; you have 20 trys left!) | |
''' | |
#matlib generator that we used in class https://storage.googleapis.com/supplemental_media/udacityu/4915289176/madlibs_generator.py | |
# A list of replacement words to be passed in to the play game function. | |
parts_of_speech1 = ["PLACE", "PERSON", "PLURALNOUN", "NOUN", "NAME", "VERB", "OCCUPATION", "ADJECTIVE"] | |
# The following are some test strings to pass in to the play_game function. | |
test_string1 = "Hi, my name is NAME and I really like to VERB PLURALNOUN. I'm also a OCCUPATION at PLACE." | |
test_string2 = """PERSON! What is PERSON going to do with all these ADJECTIVE PLURALNOUN? Only a registered | |
OCCUPATION could VERB them.""" | |
test_string3 = "What a ADJECTIVE day! I can VERB the day off from being a OCCUPATION and go VERB at PLACE." | |
# Checks if a word in parts_of_speech is a substring of the word passed in. | |
def word_in_pos(word, parts_of_speech): | |
for pos in parts_of_speech: | |
if pos in word: | |
return pos | |
return None | |
# Plays a full game of mad_libs. A player is prompted to replace words in ml_string, | |
# which appear in parts_of_speech with their own words. | |
def play_game(ml_string, parts_of_speech): | |
replaced = [] | |
ml_string = ml_string.split() | |
for word in ml_string: | |
replacement = word_in_pos(word, parts_of_speech) | |
if replacement != None: | |
user_input = raw_input("Type in a: " + replacement + " ") | |
word = word.replace(replacement, user_input) | |
replaced.append(word) | |
else: | |
replaced.append(word) | |
replaced = " ".join(replaced) | |
return replaced | |
print play_game(test_string1, parts_of_speech1) | |
''' | |
#the way I decided to solve this is to take the text: | |
#a) create a variable called 'newlist' with the string. this can be done with command: parragraph.split() | |
#b) measure the length of the list. len(newlist) | |
#c) take the result of the function number_of_guesses called "option1". and generate that many random numbers within the leng. those random numbers will be positions in the list. | |
# random.sample(xrange(1,50), 6)... random.sample(xrange(from,until), how many randome) Return a random integer N such that a <= N <= b. or 1 <= N <= number_of_guesses | |
#so the code would be random.newlist1(xrange(0,len(newlist1)), option1) | |
# save this random numbers in a new list called 'postions[]' | |
#e) I'll go through the list saving those words in a list called "answers" | |
#d) Then I'll take them and replace them with _1_, _2_, _3_, as many as instructed by the user in the function number_of_guesses. and print that. | |
#e) when the answer in _1_ = answers[0]. then we print correct. | |
#f) I'll replace "_1_" for the answer[0], and then will move to _2_. So to automate this I'll create a counter called n. and print _n_. | |
#g) when th user ansers correctly the counter n = n+1 until it reaches the number in function number_of_guesses | |
#this way we can make it variable and keep it intresting. | |
def easy_text(n): | |
length = len(newlist1) | |
print length | |
print current | |
print parragraph1 | |
print question1 | |
#print "\n The Current paragraph reads as such:" | |
#print "\nPython For Beginners. \nWelcome! Are you completely new to programming? If not then we presume you will be looking for information about why and how to get started with Python. Fortunately an experienced programmer in any programming language (whatever it may be) can pick up Python very quickly. It's also easy for beginners to use and learn, so jump in!" | |
#print "\n What should be instead of __1__?\n" | |
def medium_text(n): | |
length = len(newlist2) | |
print current | |
print parragraph2 | |
print question1 | |
#print "\n The Current paragraph reads as such:" | |
#print "nInstalling \nInstalling Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed. If you do need to install Python and aren't confident about the task you can find a few notes on the BeginnersGuide/Download wiki page, but installation is unremarkable on most platforms." | |
#print "\n What should be instead of __1__?\n" | |
def hard_text(n): | |
length = len(newlist3) | |
print current | |
print parragraph3 | |
print question1 | |
#print "\n The Current paragraph reads as such:" | |
#print "\n Looking for Something Specific? \n If you want to know whether a particular application, or a library with particular functionality, is available in Python there are a number of possible sources of information. The Python web site provides a Python Package Index (also known as the Cheese Shop, a reference to the Monty Python script of that name). There is also a search page for a number of sources of Python-related information. Failing that, just Google for a phrase including the word ''python'' and you may well get the result you need. If all else fails, ask on the python newsgroup and there's a good chance someone will put you on the right track." | |
#print "\n What should be instead of __1__?\n" | |
def shakespeare_Text(n): | |
#print "\n The Current paragraph reads as such:" | |
#print "\n Some say thy fault is youth, some wantonness,Some say thy grace is youth and gentle sport,Both grace and faults are loved of more and less:Thou mak'st faults graces, that to thee resort:As on the finger of a throned queen,The basest jewel will be well esteemed:So are those errors that in thee are seen,To truths translated, and for true things deemed. How many lambs might the stern wolf betray,If like a lamb he could his looks translate!How many gazers mightst thou lead away,if thou wouldst use the strength of all thy state!But do not so, I love thee in such sort,As thou being mine, mine is thy good report." | |
#print "\n What should be instead of __1__?\n" | |
length = len(newlist4) | |
print current | |
print parragraph4 | |
print question1 | |
#7) give them something if they win. I was thinking a phyton game (I'm goin to import basic games, just a little extra something to make this fun. lets hope this works. 1 good game if they make it and another if they lose. | |
#since this is just extra requeriment than what is asked for in the assigment I think is ok to get some code from an out source. most of this wont be original code like all the code above. | |
#I was thinking a phyton game (I'm goin to import basic games, just a little extra something to make this fun. lets hope this works. 1 good game if they make it and another if they lose. | |
def wrong_answer(): | |
#this are comments form the original code I decided to leave | |
############################################################ | |
# - My version on the game "Dragon Realm". | |
# - taken from the book "invent with python" by Al Sweigart. | |
# - thanks for a great book Mr Sweigart. | |
# - this code takes advantage of python 3. | |
############################################################ | |
#files.py | |
"""print('\n\n[--system--] wrong answer...\n') | |
print('\n\nwait while connecting....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('\nconnection established') | |
time.sleep(3) | |
""" | |
def displayIntro(): | |
print('\n------------') | |
#print('SYSTEM FILES') | |
print('------------\n') | |
time.sleep(1) | |
print('1.) try again') | |
print('2.) "exit the game"\n') | |
def chooseOption(): | |
option = '' | |
while option != 1 and option != 2: | |
print('chose between 1 or 2') | |
option = input('user:> ') | |
return option | |
def checkOption(chosenOption): | |
#goodfile = random.randint(1,2) I changed this code to not make it random, as it was initially programed for | |
#goodfile = 2 this code didnt work. I tried to rediffine goodcode. But I keep gettig the same result for both nubers | |
#if chosenOption == str(goodfile): | |
if chosenOption == 1: | |
print('\n... lets try again. see what happens when you get all the correct answers') | |
time.sleep(3) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
dificulty() | |
# time.sleep(4) | |
# print('\njust kitting!') | |
#--------- now the code shoulde direct them back to the game | |
else: | |
print('\nwinners dont quit!') | |
print('\nintialising download....') | |
time.sleep(1) | |
print('accessing all pictures in computer....') | |
time.sleep(3) | |
print('downloading and posting them on facebook....') | |
time.sleep(3) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('just kitting!') | |
time.sleep(1) | |
print('logging out... but you should really see what happens when you get them all correct!') | |
time.sleep(1) | |
exit() | |
# print('system infected.') | |
# print('\nGAME OVER') | |
displayIntro() | |
optionNumber = chooseOption() | |
checkOption(optionNumber) | |
#this is the important part of the code | |
"""playAgain = 'yes' | |
while playAgain == 'yes': | |
displayIntro() | |
optionNumber = chooseOption() | |
checkOption(optionNumber) | |
#---code come here after you chose to try again. | |
print('download again? .... (yes or no)') | |
playAgain = input(str('user:> ')) | |
""" | |
#THIS IS THE CODE IF THEY WIN!!! | |
def all_questions_answered(): | |
#import random | |
#import time | |
guessesTaken = 0 | |
print('\n\n\n\n\n[--system--] enter code in 15 trys to avoid lockout\n') | |
print('\nconnecting....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('connection established\n') | |
print('---------------------') | |
print(' MAINFRAME - LOGIN ') | |
print('---------------------') | |
print('\nenter the secret 3 digit access code:') | |
number = random.randint(000, 999) | |
while guessesTaken < 15: | |
#print() | |
guess = input('user:> ') | |
guess = int(guess) | |
guessesTaken = guessesTaken + 1 | |
if guess < number: | |
print('\nACCESS - DENIED -code to low') | |
if guess > number: | |
print('\nACCESS - DENIED -code to high') | |
if guess == number: | |
break | |
if guess == number: | |
guessesTaken = str(guessesTaken) | |
print('\nverifying ....') | |
time.sleep(1) | |
print('\nauthenticating ....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
print('....') | |
time.sleep(1) | |
#i should input a code to open a web page with a cool video like https://www.youtube.com/watch?v=LlhKZaQk860 | |
import webbrowser | |
webbrowser.open('https://www.youtube.com/watch?v=LlhKZaQk860') | |
exit(0) | |
if guess != number: | |
number = str(number) | |
print('\n....') | |
time.sleep(1) | |
print('\n....') | |
time.sleep(1) | |
print('\nSYSTEM LOCKED -the code was ' + number) | |
print() | |
exit(0) | |
#Here is the execution of commands | |
print Message1 | |
print Message2 | |
print Message3 | |
print Message4 | |
#print String1.rjust( 50 ) | |
#print String1.ljust( 50 ) What I learned here is that this formating doesnt really matters | |
dificulty() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment