Learning path for code

3887
0
05-17-2015 11:48 AM

Learning path for code

#Learning code

#Document everything

#Import needed modules
import random

#Create a function
def give_me_a_number(start,stop):
    """Get a number give me where you want to start and
    where you want to stop"""
    return random.randint(start,stop)
    
#Preset some variables
#I'm using 100 but in some cases you may need hundreds
project = give_me_a_number(0,100)
#Success is really a product of trying
success = 0
#Trying will lead to success
Keep_trying = 1
#Sometimes a little extra help is needed
Ask_for_help = 1
#Trying is not without side effects
trials_products = ("sweat","pull your hair out",
                   "search the internet","buy a book","get help")
tried = []
#Here's where the work happens :)
while project > success:
    if success%2 != 0:
        success += Ask_for_help
        x = give_me_a_number(0,20)
        if x == 0 or x < len(trials_products):
            if x not in tried:
                tried.append(x)
                print "You",trials_products
        if success == project:
            print "You've caught a break"
            break
    success += Keep_trying
print "SUCCESS"


Version history
Last update:
‎12-12-2021 03:42 AM
Updated by: