Example #1
0
def payment(request):
    if request.method == 'POST':
        dataDictionary = json.loads(request.body)
        # print dataDictionary

        transactionId = dataDictionary['transactionId']
        paymentMethod = dataDictionary['paymentMethod']

        order = Order.objects.get(transactionId=transactionId)

        if paymentMethod.lower() == "onlinepayment":
            order.paymentMethod = Order.ONLINEPAYMENT
            order.save()

        if order.paymentMethod == Order.ONLINEPAYMENT:
            message = "Thanks for paying online."
        else:
            message = "Please pay by cash on counter while collecting bag"
        estimatedWaitTime = random.rantint(10, 20)
        args = {
            "success": True,
            "message": message,
            "counter": order.counter,
            "estimatedWaitTime": estimatedWaitTime
        }
        return HttpResponse(json.dumps(args), content_type="application/json")
    else:
        status = {"status": False, "message": "Send Post request"}
        return HttpResponse(json.dumps(status),
                            content_type="application/json")
    def random_direction(self):
        #wait state r = random.randint(0,4)
        r = random.rantint(0,4)

        self.last_direction = self.directions[r]

        return self.directions[r]
Example #3
0
def ad_hoc_connections(village):
    for villager in village:
        for i in range(random.randint(1,15))
            neighbor = random.rantint(1,15)
            if villager.neighbors_list has neighbor:
                continue
            else:
                villager.neighbors_list.append(neighbor)
def pregame():
    lvlAtk = int(raw_input("attack level (0-20): "))
    lvlDef = float(raw_input("defense level (0-20): "))
    lvlHp = int((lvlDef + ((lvlDef / 4)*7) * 2 )+(lvlDef / 2 + (lvlDef / 13)*10 + (lvlDef / 23) + ((lvlDef / 7)*5) + lvlDef / 5 * lvlDef)+ 10)
    hp = lvlHp
    pickSwd = int(raw_input("Choose a Sword: \n 1. A Rusty Dagger. \n 2. A Broad Sword. \n 3. A Bastard Sword. \n 4. A Keen Short Sword. \n (1-4): "))
    if pickSwd == 1:
        sword = ("A Rusty Dagger", "The rust buildup on this 6-inch dagger has made it very dull.", 0, 1, 2, 1, False)
    elif pickSwd == 2:
        sword = ("A Broad Sword", "This 21-inch Sword is very heavy.", 5, 5, 12, 50, False)
    elif pickSwd == 3:
        sword = ("A Bastard Sword", "This Sword is nearly three feet long and requires both hands to use.", 12, 30, 36, 40, True)
    elif pickSwd == 4:
        sword = ("A Keen Short Sword", "This 12-inch classic is very sharp.", 1, 14, 24, 16, False)
    minAtk = lvlAtk * (lvlAtk/8) + sword [3] #max Base Attack 50, min Base Attack 0. Sword added post facto
    pickDef = int(raw_input("Choose your armor \n 1. Clothing. \n 2. Chain Mail. \n 3. Plate Armor. \n (1-3): "))
    if pickDef == 1:
        armor = ("Clothing", "Stylish, but does not offer much protection.", 0)
    elif pickDef == 2:
        armor = ("Chain Mail", "Armor made from interlocking rings.", .14)
    elif pickDef == 3:
        armor = ("Plate Armor", "Armor made of plates of steel", .22)
    ymax = 8
    xmax = 8
    x = (xmax / 2)                                                      # Generates user in middle (or closest to it) of room
    y = (ymax / 2)

    debug = 0
    pick3 = 0
    move = 0
    pot = 6
    spot = 3

    # Random Object Generation Node
         #key
    keyout = 1
    keyin = 0
    xkey = random.randint(0,xmax)                                       # puts the key some
    ykey = random.randint(0,ymax)
         #locator
    locatorout = 1
    locatorin = 0
    xlocator = random.randint(x-1,x+1)
    ylocator = random.randint(y-1,y+1)
         #door
    ydoor = random.randint (0,ymax)
    l=0
        # enemies
    bad1 = ["A Giant Rat", "This overgrown vermin will attack at the slightest provocation. Otherwise, it will just eat grain.", 10, 3, 6]
    xbad1 = random.randint(0,8)
    ybad1 = random.randint(0,8)
    bad2 = ["A Cave Ghoul", "This monster doesn't want you in his Big Room.", 80, 6, 9]
    xbad2 = random.randint(0,8)
    ybad2 = random.randint(0,8)
    bad3 = ["A Wild Marcus Darden", "With terrifying dreadlock whips and soothingly low voice, this feind is a double threat", 120, 10, 25]
    xbad3 = random.randint(0,8)
    ybad3 = random.rantint(0,8)
    game = 1
Example #5
0
def one_cycle(village):
    for villager in village:
        village

        for i in range(random.randint(1,15))
            neighbor = random.rantint(1,15)
            if villager.neighbors_list has neighbor:
                continue
            else:
                villager.neighbors_list.append(neighbor)
Example #6
0
def displayrandompixel(seconds):
    from gfxhat import lcd
    import random, time
    lcd.clear()

    x = random.rantint(1, 128)
    y = random.randint(1, 64)
    lcd.set_pixel(x, y, 1)
    lcd.show()
    time.sleep(seconds)
    lcd.clear()
def payment(request):
    if request.method == 'POST':
        dataDictionary = json.loads(request.body)
        # print dataDictionary

        transactionId = dataDictionary['transactionId']
        paymentMethod = dataDictionary['paymentMethod']

        order = Order.objects.get(transactionId = transactionId)

        if paymentMethod.lower() == "onlinepayment":
            order.paymentMethod = Order.ONLINEPAYMENT
            order.save()

        if order.paymentMethod == Order.ONLINEPAYMENT:
            message = "Thanks for paying online."
        else:
            message = "Please pay by cash on counter while collecting bag"
        estimatedWaitTime = random.rantint(10,20)
        args = { "success": True,  "message": message, "counter" : order.counter, "estimatedWaitTime" : estimatedWaitTime}
        return HttpResponse(json.dumps(args), content_type = "application/json")
    else:
        status = {"status" :False,"message": "Send Post request" }
        return HttpResponse(json.dumps(status), content_type = "application/json")
	def noPref(self, x=None):
		return random.rantint(0,99)
Example #9
0
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import random
>>> random.randint()
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    random.randint()
TypeError: randint() missing 2 required positional arguments: 'a' and 'b'
>>> random.randing(1,10)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    random.randing(1,10)
AttributeError: module 'random' has no attribute 'randing'
>>> random.rantint(1,30)
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    random.rantint(1,30)
AttributeError: module 'random' has no attribute 'rantint'
>>> random.randint(1,3)
1
>>> 
>>> random.randint(1,10)
7
>>> import random
>>> import random, sys, os, math
>>> from random import *
>>> randint(1,10)
5
>>> sys.exit()
>>> 
>>> 
Example #10
0
def rollDie():
    return random.rantint(1,12)
Example #11
0
def gioco():
	global adepti
	global soldi
	global vaccinati, popolazione, nonvaccinati, turno, morti
	turno = turno + 1
	soldi = soldi + (adepti*0.5)
	soldi = int(soldi)
	soldi = soldi - 250
	if vaccinati > 1000:
		vaccinati = 1000
		nonvaccinati = 0
	if adepti < 0:
		adepti = 0
	print "*"*10
	if morti > 300:
		print "Un magistrato si sveglia e ti manda in galera per omicidio e epidemia colposa. Pace amen"
		essit()
	if vaccinati < 800:
		print "Immunità di gregge danneggiata \n"
		morti = morti + random.rantint(1,25)
	print turno, "° turno"
	print "Possiedi ", soldi, "Euro"
	print "Hai", adepti, "adepti"
	print "Percentuale Vaccinati: ", vaccinati/10
	print "Morti a causa tua:", morti
	if soldi < 0:
		print "Sei senza soldi"
		essit()
		
	print"""
Menù di gioco \n
1) Studio scientifico falso \n
2) Finanzia false cure \n
3) Cause per danni da vaccino \n
4) Finanzia blog fuffari \n
5) Minaccia di denunzia i debunker \n
6) Campagna pubblicitaria
"""
	kappa = input(">>")
	if kappa == 1:
		print "Vuoi spendere 15000 € per finanziare uno studio sui danni da vaccino, ovviamente falsi?"
		ll = raw_input("Si per accettare: ")
		if ll == "Si":
			soldi = soldi - 15000
			adepti = adepti + 50
		if random.randint(1,10) > 6:
			nonvaccinati = nonvaccinati + 5
			vaccinati = vaccinati - 5

	elif kappa == 2:
		print "Vuoi spendere 10000€ per finanziare un naturopata per curare i danni da vaccino?"
		ll = raw_input("Si per accettare: ")
		if ll == "Si":
			soldi = soldi - 10000
			adepti = adepti + 25
	elif kappa == 3:
		if random.randint(1,10):
			print "Hai vinto la causa: La famiglia verrà risarcita con 100000€ e tu ne prenderai il 10%"
			soldi = soldi + 10000
		else:
			print "Perdi la causa e spendi 10000€ di spese legali"
			soldi = soldi - 10000
	elif kappa == 4:
		print "Dai 1000€ a dei blog fuffari"
		soldi = soldi - 1000
		adepti = adepti + 25
	elif kappa == 5:
		print "Minacci di denuncia i debunker"
		adepti = adepti + random.randint(-5,5)
		ukulele = random.randint(-15,15)
		vaccinati = vaccinati + ukulele
		nonvaccinati = nonvaccinati - ukulele
	elif kappa == 6:
		print """Che campagna vuoi avviare?
1) Rivista (1000€)
2) Trasmissione TV (2000€)
3) Blog fuffaro (5000€)
4) Famiglia finta (10000€)
5) Esci
"""
		camp = input(">")
		if camp == 1:
			adepti = adepti + 30
			soldi = soldi - 1000
		elif camp == 2:
			adepti = adepti + 40
			nonvaccinati = nonvaccinati + 2
			vaccinati = vaccinati - 2
			soldi = soldi - 2000
		elif camp == 3:
			adepti = adepti + 50
			nonvaccinati = nonvaccinati + 4
			vaccinati = vaccinati - 4
			soldi = soldi - 5000
		elif camp == 4:
			adepti = adepti + 50
			nonvaccinati = nonvaccinati + 5
			vaccinati = vaccinati - 5
			soldi = soldi - 10000
			
			

	raw_input("Premi invio per continuare")
		
		
	poss()	
Example #12
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient
import random 

 
def messageparse(body):
	comps = ["Hey Sexy"]
    if " " in body:
        return [body[:body.index(" ")],body[body.index(" ")+1:]]
    else: return [body, comps[random.rantint(0,len(comps))]]


def sendmessage(client, tonumber, compliment):
    message = client.messages.create(body=compliment,
        to=tonumber,
        from_="+16267747161",)
    #media_url="http://www.example.com/hearts.png")
    print message.sid


account_sid = "AC66feb8a0982d83f73782a94069212ed7"
auth_token  = "34ddec2af3dad454914b40280328c820"
client = TwilioRestClient(account_sid, auth_token)

textbody = messageparse(somemessage.body)
sendmessage(client, "3233933245", textbody[1])
#not aryas # but we're going to use his # to keep checking
Example #13
0
 def attack(self):
     roll = random.rantint(1, self.attackLimit)
     return roll > 4
Example #14
0
 def cwheel(self):
     global match_time
     if match_time >= 10:
         match_time -= random.rantint(5,10)
     else:
         match_time -= random.randint(1,match_time)
import random

LOESUNG = random.rantint(1, 10)


def main():
    # diese Funktion wird aufgerufen wenn der Code ausgeführt wird

    antwort = int(
        input(
            "Ich habe mir eine Zahl ausgedacht. Es ist eine Zahl zwischen 0 und 10. Kannst du sie erraten? "
        ))

    while LOESUNG != antwort:
        if LOESUNG < antwort:
            print("Das ist leider falsch. Meine Zahl ist kleiner als das.")
        else:
            print("Das ist leider falsch. Meine Zahl ist größer als das.")
        antwort = int(input("Versuch es nochmal "))

    print("Das ist richtig!")


# Bitte keinen Code unter diesem Kommentar schreiben
if __name__ == '__main__':
    main()