Skip to content

Instantly share code, notes, and snippets.

@Neyt
Last active June 16, 2016 05:08
Show Gist options
  • Save Neyt/2944ba04ee769757d5c1c1ae3e9e2496 to your computer and use it in GitHub Desktop.
Save Neyt/2944ba04ee769757d5c1c1ae3e9e2496 to your computer and use it in GitHub Desktop.
import random
option1 = 0
lengthoflisteasy = 0
counter1 = 0
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!\n\n"
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.\n\n"
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.\n\n"
newlist1 = parragraph1.split()
newlist2 = parragraph2.split()
newlist3 = parragraph3.split()
question = ()
answers1 = () #here is where the user inputs their answers.
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
counter2 = []
newparragraphx = ()
dificultyfinal = 0
text = ()
replacementword = ()
numbertoreplace = ()
def textreplaced(numbertoreplace,replacementword): #takes variable text and replaces numbers with correct asnwers
new_text_replaced= (str(text)).replace(str(numbertoreplace),str(replacementword))
return new_text_replaced
def text(x): #takes the text created with incognitos and saves it to change it as its being solved
global text
text = x
print text
def newparragraphx(counter1): #selects a different text depending on the level of difficulty
if counter1 == 1:
list_to_be_join = newlist1
elif counter1 == 2:
list_to_be_join = newlist2
elif counter1 ==3:
list_to_be_join = newlist3
else:
list_to_be_join = newlist1
i = 0
while i < counter1[-1]:
number = str("__"+str(counter[i])+"__")
list_of_solutions = str(solution[i])
exact_position = position[i]
list_to_be_join.remove(list_of_solutions)
list_to_be_join.insert(exact_position, number)
i=i+1
w =str((" ").join(list_to_be_join))
text(w)
def dificultyfinal(x):#stores difficulty level in a different function so it can be manipulated (as answers are being delivered) without affecting the intial difficulty input
global dificultyfinal
dificultyfinal = x
def run():#basically runs the code after def dificulty()
number_of_guesses()
execution()
replacenumber()
def dificulty():#2) asks you for a difficulty#Game has 3 or more levels and each level contains 4 or more blanks to fill in
print '\n\nPlease chose the difficulty level number from 1 to 4:'+'\n1.Easy'+'\n2.Medium'+'\n3.Hard'+'\n4.Exit'
option = int(input('user:> '))
try:
if option == 1:
dificultyfinal == 1
run()
elif option == 2:
dificultyfinal == 2
run()
elif option == 3:
dificultyfinal == 3
run()
elif option == 4:
exit()
else:
exit()
except:
dificulty()
def counter2(option1):#is a def that takes the number of tries you are going to make and stores it
a=range(1,option1+1)
global counter1
counter1 = a
def number_of_guesses():#4) Let the user decide how many wrong guesses they can make before they lose.
lengthoflisteasy = str(len(newlist1))
print "\nHow many guesses would you like per problem?"
print "(please enter a possitive integer number from 1 to " + lengthoflisteasy+")"
option1 = int(input('user:> '))
counter2(option1)
option1 = counter1
return option1
def replacenumber(): #ask "What should be substituted in for __#__? and starts a loop until the puzzle is solved"
loop_counter=0
question = "\n What should be instead of __"+str(counter1[loop_counter])+"___? (Answers are Upper Case sensitive)\n"
print question #+ option1 #I have to make option1 global and I cant yet
while loop_counter < counter1[-1]:
answers1 = str(raw_input('\nuser:> '))
if answers1 in solution:
replacementword = answers1
numbertoreplace = loop_counter+1
print "\nYou got it!"
solution.pop(loop_counter) #
loop_counter = loop_counter+1
print "\n " + textreplaced(numbertoreplace,replacementword)
print "\n What should be instead of __"+str(counter1[loop_counter])+"___?"
else:
print text+"\n\n\n Incorrect, What should be instead of __"+str(counter1[loop_counter])+"___?"
def execution():#exectues the program. take the iser input and creates random lists to be guesses.
try:
loop_counter = 0
while loop_counter < counter1[-1]:
b = random.choice(newlist1) # this prints random names
solution.append(b)
y = newlist1.index(b)
position.append(y)
loop_counter = loop_counter+1
counter.append(loop_counter)
print "\n\nHere is the Quiz:\n\n"
print newparragraphx(counter1)
except:
print newparragraphx(counter1)
def all_questions_answered():#THIS IS THE CODE IF THEY WIN!!!
print "you win"
exit(0)
dificulty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment