Пример #1
0
def earn():
    if request.form['action'] == 'farm':
        earn = int(random.randrang(10, 21))

    elif request.form['action'] == 'cave':
        earn = random.randrang(5, 11)

    elif request.form['action'] == 'house':
        earn = random.randrang(2, 6)

    else:  #request.form['action'] == 'casion':
        earn = random.randrang(0, 51)

    # print earn
    #if 'earn' not in session:
    #	session['earn'] = earn

    #if request.form['action'] == 'register':
    #//do registration process
    #elif request.form['action'] == 'login':
    #//do login process

    return redirect('/')
Пример #2
0
        def select_greedy_action(state, hx, cx, model, isTrain):
            nonlocal steps_done #what is nonlocal? here says: statement seems to have no effect

            sample = random.random()

            eps_threshold = EPS_END + (EPS_START - EPS_END) * \
                math.exp(-1. * steps_done / EPS_DECAY)
            steps_done += 1

            if sample > eps_threshold:
                state = torch.from_numpy(state).float().unsqueeze(0) #what
                probs = dqn(Variable(state, volatile = True))

                return probs.data.max(1)[1].cpu(), None, None, None #this gets index of max log-probability, apparently

            else:
                return torch.LongTensor([[random.randrang(actions)]]), None, None, None #why double []s?
Пример #3
0
import webbrowser
import time
import random

while True:
    sites = random.choice(['https://www.youtube.com/watch?v=vLRyJ0dawjM', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'https://www.youtube.com/watch?v=FpFztrJbksg'])
    webbrowser.open(sites)
    seconds = random.randrang(0,2)
    time.sleep(seconds)
#Import libraries
import wbbrowser
import time
import random

# Setup the while loop
while True:
    # Choose the sites
    sites = random.choice(
        ["google.com", "github.com", "youtube.com", "weather.gov"])
    # Setup the first part fpr tje webbrowser to search
    visit = "http://{}".fromat(sites)
    # Have the webbrowser open the random site to visit
    webbrowser.open(visit)
    # Pick a random number betweem 5 and 20 which will then open a site
    seconds = random.randrang(5, 20)
    # Wait x(seconds variable).
    time.sleep(seconds)
Пример #5
0
import random
escape_door = random.randrang(1, 50)

if roomcounter == rooms[escape_door]:
    escape_room_code()


def escape_room_code(motion):
    print(
        "Congratulations! You have found the final door, after probably wandering around aimlessly and wasting your afternoon. This is the final question. If you get this question wrong, you lose, and the time spent playing this spectacular program that definitely deserves a 100% will truly be wasted. Good luck; you only have one try."
    )
    current_riddle = rooms[roomcounter][motion]['riddle']
    response = input(f"{current_riddle}").lower()
    if response == current_door['answer']:
        print("CONGRATULATIONS! YOU BEAT THE GAME. WONDERFUL JOB.")
        break
    else:
        print(
            "Wow, really. The last question and you manage to get it wrong. I am a little disappointed. Now you can either play again or go and thing about what you've done."
        )
        print("YOU LOSE.")
        break
Пример #6
0
import random
from firebase import firebase

firebase = firebase.FirebaseApplication(
    'https://temp-438dc.firebaseio.com/temper', None)
result = firebase.post('/temper', {'ID': random.randrang(100, 99, 6)})
#print ('HEELO EVERYONE')
#print (random.randrang(10000, 99999, 6))
result = firebase.get('/users', None)
print(result)
{'1': 'John Doe', '2': 'Jane Doe'}
Пример #7
0
def random_number(max_int):
    rand = random.randrang(0, max_int)
    return rand
    a_number = random_number(5)
    print(a_number)
Пример #8
0
2
>>> print(c)
(1+0j)
>>> 
>>> print(type(a))
<class 'float'>
>>> print(type(b))
<class 'int'>
>>> print(type(c))
<class 'complex'>
>>> 
>>> 
>>> impoort random
SyntaxError: invalid syntax
>>> import random
>>> print(random.randrang(1,10))
Traceback (most recent call last):
  File "<pyshell#147>", line 1, in <module>
    print(random.randrang(1,10))
AttributeError: module 'random' has no attribute 'randrang'
>>> print(random.randrang(1,10))
Traceback (most recent call last):
  File "<pyshell#148>", line 1, in <module>
    print(random.randrang(1,10))
AttributeError: module 'random' has no attribute 'randrang'
>>> 
>>> import random
>>> print(random.randrange(1,10))
9
>>> 
>>> # done